Template inheritance in odoo

Minh-Hung Nguyen picture Minh-Hung Nguyen · Dec 22, 2014 · Viewed 16.8k times · Source

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.

Answer

Ludwik Trammer picture Ludwik Trammer · Dec 22, 2014

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.