Skip to content

Odoo 'Field X does not exist' After Module Upgrade — Fix

DeployMonkey Team · March 22, 2026 8 min read

What This Error Means

ValueError: Field 'x_custom_field' does not exist in model 'sale.order'

This error occurs when an XML view references a field that does not exist in the model. It most commonly happens after module upgrades when fields are renamed, removed, or moved to a different module.

Cause 1: Custom Module Field Removed

When: You removed a field from a custom module's Python model but forgot to remove it from the XML views.

Fix: Search for the field name in all XML files and remove or replace references:

grep -rn 'x_custom_field' your_module/views/
# Remove or update all matching lines

Cause 2: Odoo Core Field Renamed in New Version

When: Upgrading Odoo versions. Core fields get renamed or restructured.

Common examples:

  • Odoo 17: Various field renames in accounting and sale modules
  • Odoo 18: group_operatoraggregator
  • Odoo 19: Some field reorganizations in ORM refactoring

Fix: Check the release notes for your target version and update field references.

Cause 3: Inherited View References Missing Field

When: Your module inherits a core view and adds a field. The dependency module that provides the field is not installed or was uninstalled.

Fix: Ensure all dependencies are listed in __manifest__.py:

# __manifest__.py
'depends': ['sale', 'the_module_that_provides_the_field'],

Cause 4: Database Has Stale View Records

When: A module was partially uninstalled or updated, leaving orphan view records in the database.

Fix:

# Find the problematic view
SELECT id, name, model, arch_db 
FROM ir_ui_view 
WHERE arch_db LIKE '%x_custom_field%';

# Option 1: Delete the orphan view
DELETE FROM ir_ui_view WHERE id = ;

# Option 2: Update the view to remove the field reference
# (More precise, preserves the rest of the view)

Cause 5: Computed Field Without Dependencies

When: A computed field references another field that was removed.

Fix: Update the compute method and @api.depends to remove references to the deleted field.

Debugging Steps

  1. Read the full error message — it tells you the exact field name and model
  2. Search for the field in your custom module: grep -rn 'field_name' your_module/
  3. Check if the field exists in the model: self.env['model.name']._fields.get('field_name')
  4. If it is a core Odoo field, check the changelog for your version
  5. If it is from another module, verify the module is installed

Prevention

  • Always test upgrades on staging first — catch field errors before production
  • Use AI coding tools — Claude Code detects field references that do not match the model definition
  • Keep __manifest__.py dependencies accurate — missing dependencies cause field errors

DeployMonkey

DeployMonkey's AI agent detects field-does-not-exist errors in logs immediately after module upgrades and provides specific fix recommendations — which view, which field, and whether to update or remove the reference.