1.3 KiB
1.3 KiB
XPath Patterns for Odoo View Inheritance
Common XPath Positions
before- Insert before the target elementafter- Insert after the target elementinside- Insert inside the target element (as last child)replace- Replace the target element entirelyattributes- Add/modify attributes of the target element
Examples
Add Field After Another Field
<xpath expr="//field[@name='partner_id']" position="after">
<field name="new_field"/>
</xpath>
Add Field Inside Group
<xpath expr="//group[@name='group_name']" position="inside">
<field name="new_field"/>
</xpath>
Replace Field
<xpath expr="//field[@name='old_field']" position="replace">
<field name="new_field"/>
</xpath>
Add Attributes
<xpath expr="//field[@name='field_name']" position="attributes">
<attribute name="readonly">1</attribute>
<attribute name="required">1</attribute>
</xpath>
Add to Header
<xpath expr="//header" position="inside">
<button name="action_custom" string="Custom" type="object"/>
</xpath>
Add Notebook Page
<xpath expr="//notebook" position="inside">
<page string="New Page">
<group>
<field name="field1"/>
</group>
</page>
</xpath>