How to extend/overrule/override <record>?

  • type
      technical
  • info created for version
      14.0
  • mvc
      XML (records/views/templates)
Add to Cart

<record>s of model 'ir.ui.view' have an inherit_id property ...

<record id="product_template_search_view" model="ir.ui.view">
    <field name="model">product.template</field>
    <field name="inherit_id" ref="product.product_template_search_view" />
    <field name="arch" type="xml">
        <field name="name" position="after">
            <field name="product_brand_id" />
        </field>
    </field>
</record>


<record>s of models other than 'ir.ui.view' do not work with an inherit_id. If you want to change a field value of a record, you should copy the definition of the <record> in your module, prefix the id with the original module name (+ dot) and include the field you wish to change like for example ...

<record id="purchase_requisition.type_multi" model="purchase.requisition.type">
   <field name="exclusive">exclusive</field>
</record>


 If that <record> is wrapped in a noupdate="1" you should make the record writable first (and unwritable again after) like this ...

<odoo noupdate="0">
   <function name="write" model="ir.model.data">
      <function name="search" model="ir.model.data">
         <value eval="[('module', '=', 'purchase_requisition'), ('name', '=', 'type_multi')]"/>
       </function>
      <value eval="{'noupdate': False}" />
   </function>
   <record id="purchase_requisition.type_multi" model="purchase.requisition.type">
       <field name="exclusive">exclusive</field>
   </record>
   <function name="write" model="ir.model.data">
      <function name="search" model="ir.model.data">
         <value eval="[('module', '=', 'purchase_requisition'), ('name', '=', 'type_multi')]"/>
      </function>
      <value eval="{'noupdate': True}" />
   </function>
</odoo>