How to inherit from a view without overriding the original view

If you need to create a new view that is very similar to existing one. Instead of creating the whole view you can inherit from the existing view and set the attribute “mode” to “primary“. In that way, the original view will not be changed and all changes in the newly created view will apply only for it.

For example, if you need new crm.lead form view that has new field “mobile“, but this field should be shown only in the new view, not in the original one, the code should look like

        <record id="view_crm_lead_form_mobile" model="ir.ui.view">
            <field name="model">crm.lead</field>
            <field name="inherit_id" ref="crm.view_crm_lead_form" />
            <field name="mode">primary</field>
            <field name="arch" type="xml">
                <field name="phone" position="after">
                    <field name="mobile"/>