Odoo XML View Inheritance Migration
XPath expressions in view inheritance can silently break when Odoo changes the underlying view structure between versions. This guide covers the risk and how to audit and fix it.
The problem
XPath expressions in view inheritance (<xpath expr="..." position="...">) can break when Odoo changes the parent view's structure, renames a field, or reorders nodes between versions.
Why it matters
An inherited view that cannot locate its target node raises a view inheritance error at install or upgrade time. A single failing XPath can block the whole module from loading.
Common symptoms
- Element cannot be located in parent view errors
- Inherited fields or buttons missing from the form
- Module fails to upgrade after a version bump
- Views partially apply, leaving the layout inconsistent
Example risk
An XPath targeting //field[@name='date_order'] may fail if the field was renamed or the parent node structure changed in the target version:
<xpath expr="//field[@name='date_order']" position="after">
<field name="x_priority"/>
</xpath>If date_order no longer exists in the parent view, the inheritance fails and must be retargeted to a node that still exists.
How to audit it
- Run static analysis of every
xpathexpression against known Odoo view changes. - Manually review each inherited view in the target version's parent view.
- Prefer field-name selectors over positional selectors where possible.
How Odoo Doctor helps
The Migration Audit detects XPath view inheritance patterns and flags them as risks requiring manual verification, with the file and line where each selector appears. See the XPath view inheritance risk finding for details.
Manual testing needed
Install the module on a clean target database and open every inherited view. Confirm each added field, button, and group appears in the expected position.
Find fragile XPath selectors
Scan your module and review view inheritance risks before upgrading.
Run Migration AuditFrequently asked questions
Why do XPath selectors break between Odoo versions?
Inherited views target nodes in a parent view by structure or attribute. When Odoo renames a field, reorders nodes, or changes the parent view layout, an XPath that matched before no longer resolves and the view fails to render.
Is targeting by field name safer than positional XPath?
Usually yes. An expression like //field[@name='x'] is more stable than //form/sheet/group[1]/field[2], because field names change less often than structural position. Still verify the field exists in the target view.
Can the audit confirm my XPath will resolve on the target?
No. The Migration Audit flags XPath inheritance patterns as risks that require manual verification against the target version's parent view. It cannot render the parent view to confirm a match.
What happens if an XPath fails at install time?
Odoo raises a view inheritance error and the module fails to install or upgrade. Reviewing flagged XPath expressions before upgrading avoids these blocking errors.