View Inheritance Errors in Odoo
When extending or modifying existing views, you may encounter:
ValueError: External ID not found in the system: sale.view_order_form
ParseError: view 'my_module.view_order_form_inherit'
cannot inherit from 'sale.view_order_form' which does not exist
ERROR: View my_module.view_partner_form_custom has an invalid parent view referenceUnderstanding View Inheritance
Odoo uses inherit_id to extend existing views. The chain must be valid:
sale.order.form
sale.order
sale.order.form.inherit.my_module
sale.order
Fix 1: Missing Module Dependency
The most common cause — your module does not depend on the module that defines the parent view:
# __manifest__.py
{
'name': 'My Module',
'depends': ['sale'], # MUST include the module that defines the parent view
}
# Without this dependency:
# - The parent module may not be installed
# - Even if installed, Odoo may load your module first
# - The parent view won't exist when your inherit_id is processedFix 2: Wrong External ID Reference
Fix 3: Find the Correct View External ID
# Via database
sudo -u postgres psql -d mydb -c "
SELECT imd.module || '.' || imd.name as external_id, v.name, v.model
FROM ir_ui_view v
JOIN ir_model_data imd ON imd.res_id = v.id AND imd.model = 'ir.ui.view'
WHERE v.model = 'sale.order' AND v.inherit_id IS NULL
ORDER BY v.priority;
"
# Via Odoo shell
view = env.ref('sale.view_order_form')
print(f"View: {view.name}, Model: {view.model}, ID: {view.id}")Fix 4: Parent View Was Removed or Renamed
After an Odoo version upgrade, some views change their external IDs:
# Check if the view exists in the new version
# Search Odoo source code for the XML ID
grep -r 'id="view_order_form"' /opt/odoo/odoo/addons/sale/
# If renamed, update your inherit_id:
# Old (Odoo 16): sale.view_order_form
# New (Odoo 17): sale.sale_order_view_form
Fix 5: Conditional View Inheritance
If you want the view to work whether or not the parent module is installed:
# Option: Check in __manifest__.py
# Make the parent module a hard dependency
'depends': ['sale'] # Module won't install without sale
# Or use a bridge module pattern:
# my_module (core features)
# my_module_sale (sale-specific views, depends on both)Fix 6: Stale View References After Uninstall
# If you uninstalled a module but its views remain:
sudo -u postgres psql -d mydb -c "
-- Find orphaned inherited views
SELECT v.id, v.name, v.key
FROM ir_ui_view v
WHERE v.inherit_id IS NOT NULL
AND v.inherit_id NOT IN (SELECT id FROM ir_ui_view);
-- Delete orphaned views
DELETE FROM ir_ui_view
WHERE inherit_id IS NOT NULL
AND inherit_id NOT IN (SELECT id FROM ir_ui_view);
"Debugging View Inheritance
# View the full inheritance chain
sudo -u postgres psql -d mydb -c "
WITH RECURSIVE view_tree AS (
SELECT id, name, key, inherit_id, 0 as depth
FROM ir_ui_view WHERE key = 'sale.view_order_form'
UNION ALL
SELECT v.id, v.name, v.key, v.inherit_id, vt.depth + 1
FROM ir_ui_view v
JOIN view_tree vt ON v.inherit_id = vt.id
)
SELECT depth, key, name FROM view_tree ORDER BY depth;
"Prevention
DeployMonkey's AI agent validates view inheritance chains during module development. Missing dependencies and incorrect external ID references are detected before deployment.