Odoo Template Extend in Custom Module

Template Extend - Inheritance Odoo

Probuse Admin
Odoo Tips by Probuse Consluting Service Pvt Ltd

A Great Headline

A good subtitle


Concept of template inheritance:

How to inherit template

Main Template:

<t t-name="UserMenu">
    <span class="my_account">My Account</span>

Menu have options: ['My Account']

    <t t-extend="UserMenu">


* Append (it will place new element after selected element)
    <t t-extend="UserMenu">
        <t t-jquery="span.my_account" t-operation="append">
            <span class="logout">Logout</span>

Menu have options: ['My Account', 'Logout']

* Prepend (it will place new element before selected element)
    <t t-extend="UserMenu">
         <t t-jquery="span.my_account" t-operation="prepend">
             <span class="preference">Preference</span>

Menu have options: ['Preference', 'My Account']

* Replace (it will replace element with new element)
    <t t-extend="UserMenu">
         <t t-jquery="span.my_account" t-operation="replace">
              <span class="my_account_new">My Account New</span>

Menu have options: ['My Account New']

* Add element attributes (we can add attributes using js)

<div t-extend="UserMenu">
        <t t-jquery="span.my_account">
            this.attr('t-if', 'widget.session.is_admin');
- It will add t-if attribute on My Account span.