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

59 lines
1.3 KiB
Markdown

# 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
```xml
<xpath expr="//field[@name='partner_id']" position="after">
<field name="new_field"/>
</xpath>
```
### Add Field Inside Group
```xml
<xpath expr="//group[@name='group_name']" position="inside">
<field name="new_field"/>
</xpath>
```
### Replace Field
```xml
<xpath expr="//field[@name='old_field']" position="replace">
<field name="new_field"/>
</xpath>
```
### Add Attributes
```xml
<xpath expr="//field[@name='field_name']" position="attributes">
<attribute name="readonly">1</attribute>
<attribute name="required">1</attribute>
</xpath>
```
### Add to Header
```xml
<xpath expr="//header" position="inside">
<button name="action_custom" string="Custom" type="object"/>
</xpath>
```
### Add Notebook Page
```xml
<xpath expr="//notebook" position="inside">
<page string="New Page">
<group>
<field name="field1"/>
</group>
</page>
</xpath>
```