Files
gh-jamshu-jamshi-marketplac…/skills/odoo-feature-enhancer/references/xpath_patterns.md
2025-11-29 18:50:04 +08:00

1.3 KiB

XPath Patterns for Odoo View Inheritance

Common XPath Positions

  • before - Insert before the target element
  • after - Insert after the target element
  • inside - Insert inside the target element (as last child)
  • replace - Replace the target element entirely
  • attributes - 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>