How to override a view in Odoo

Odoo is great when we talk about customization of existing modules to our needs. I have shared some tips about models inheritance and customization before, but Odoo allows an easy way of changing views also.

You can override an existing view by specifying the parent view as a value in the inherit_id attribute in the view definition.

For example, if you want to override crm.lead form view in order to add an additional field mobile after the existing phone field you can do that in the following way:

<openerp>
    <data>
        <record model="ir.ui.view" id="view_crm_lead_form_inherited">
            <field name="model">crm.lead</field>
            <field name="inherit_id" ref="crm.view_crm_lead_form" />
            <field name="arch" type="xml">

                <field name="phone" position="after">
                    <field name="mobile"/>
                </field>

            </field>
        </record>
 
    </data>
</openerp>

 

Share the knowledge!

Leave a Reply

Your email address will not be published.