Deprecated states View Attribute
A finding from the Migration Audit that flags the states attribute on XML view field tags, deprecated starting in Odoo 16.
What This Finding Means
The Migration Audit detected the states attribute on an XML view field tag. This shorthand tied field visibility and readonly behavior to a record's state field. In Odoo 16 and later it is deprecated in favor of explicit Python-side field modifiers.
Why It Matters
Views that still use states emit deprecation warnings in Odoo 16 and may fail to load in Odoo 17 and later. The attribute also assumes a single state field, which is brittle when workflows change between versions.
Old Odoo Example
<field name="name" states="done:readonly"/>
Target Version Risk
- Odoo 16 — deprecation warning at view load time
- Odoo 17 and later — potential break, view may fail to parse
Recommended Fix Direction
Move the states logic into Python. Replace the shorthand with a computed boolean field (for example name_readonly = fields.Boolean(compute='_compute_name_readonly')) and reference it through the modern readonly attribute on the field tag, which accepts a Python expression.
How to Verify Manually
Open the form view in the target Odoo version and move the record through each value of its state field. Confirm the field becomes readonly exactly where the original states shorthand intended.
Related Odoo Doctor Tool
The Migration Audit scans your views for deprecated attributes and lists each occurrence so you can review them before upgrading.
Run Migration Audit