Odoo 16 Development Book

View Inheritance

There are numerous view types in Odoo. In Odoo, you must first inherit the pertinent view before making any alterations to an existing view. It is possible to inherit any view, including form, tree, kanban, search, etc. To inherit a view, you must make an XML file for the inheritance in the views folder. Include this file path inside the data manifests as well. The inherited records can be added to the XML file.

i.e.,

<record id="view_crm_meeting_search" model="ir.ui.view">
        <field name="name">calendar.event.form.inherit</field>
        <field name="model">calendar.event</field>
        <field name="inherit_id" ref="calendar.view_calendar_event_search"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='description']" position="after">
                <field name="opportunity_id"/>
            </xpath>
        </field>
     </record>

Here, the form view calendar event search, which is inside the module calendar, is inherited. The parent view id that you want to inherit is specified using the inherit id function. For the inheritance, you can add module name.parent view id. After that, you can make adjustments using the XPath tag. Additionally, you can specify several XPath values.

Expressions can be added in a variety of ways:

Some examples are

expr="//field[@name='user_id']"
expr="//sheet/div[last()]"
expr="/kanban"
expr="."
expr="//filter[@name='activities_overdue']
expr="//header"
expr="//button[@name='action_open_product_lot']"

Also you can give different positions to the xpath. i.e.,

position=”after” : Display the field after the parent view mentioned in “expr”

position=”before” : Display the field before the parent view mentioned in “expr”

position=”inside” : Display the field inside the parent view mentioned in “expr”

position=”attributes” : Change the field attributes

position=”replace” : Replace the parent view field with newly created field

location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message