Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Template inheritance in odoo

I want to create a new theme for odoo. I have done it by create a new module and install it. I see in this document here which said that odoo support template inheritance by using t-extend keyword. However I can't make it. This is my customized template:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
    <template id="website.homepage" name="Homepage" page="True">
        <div class="header">
            <h1>FOO<h1>
            <div class="main">
            </div>
        </div>
    </template>

    <template id="website.contact" name="Homepage" page="True">
        <t t-extend="website.homepage">
            <t t-jquery="div.main" t-operation="inner">
                <h1>FOO 2</h1>
            </t>
        </t>
    </template>

</data>
</openerp>

Template website.contact should have showed FOO and FOO 2 but it only showed FOO 2. Please help me explain it. Thanks.

like image 803
Minh-Hung Nguyen Avatar asked Dec 22 '14 16:12

Minh-Hung Nguyen


1 Answers

You use a syntax for client side templates, but those are server side templates. You use inheritance with server side templates this:

<template id="contact" inherit_id="website.homepage">
    <xpath expr="//div[@class='main']" position="inside">
        <h1>FOO 2</h1>
    </xpath>
</template>

You can read more in the official documentation.

like image 74
Ludwik Trammer Avatar answered Sep 20 '22 19:09

Ludwik Trammer