Odoo attrs/states Deprecation
Odoo 16 deprecated the attrs and states attributes on view field tags. This guide covers the replacement approach and how to audit custom modules.
The problem
Modules that set field visibility or editability through attrs and states will show warnings or fail to install on Odoo 16 and later, because these attributes were removed in favor of direct modifier expressions.
Why it matters
Field modifiers control which fields are visible, readonly, or required in each state of a record. If they stop applying, users can edit fields that should be locked or miss fields they need, which affects data integrity and workflows.
Common symptoms
- Module install warnings about deprecated attributes
- Fields that no longer respect readonly or invisible rules
- View rendering errors after a version upgrade
Example risk
A readonly modifier on Odoo 15 written with attrs must move to a direct expression for Odoo 16+:
<field name="user_id"
attrs="{'readonly': [('state', '=', 'done')]}"/><field name="user_id"
readonly="state == 'done'"/>Where the logic is complex, move it to a computed field or computed modifier on the Python model instead of the view.
How to audit it
- Scan XML views for
attrs=andstates=attributes. - Identify the Python model side that may need new computed field logic.
- Translate each domain into the equivalent direct modifier expression.
How Odoo Doctor helps
The Migration Audit flags deprecated attrs and states attributes with the file and line number. See the deprecated attrs and deprecated states findings for details.
Manual testing needed
Install on a clean target database and step through each record state. Confirm fields become visible, readonly, or required exactly as the original modifiers intended.
Locate deprecated view attributes
Scan your module to find every attrs and states usage with its location.
Run Migration AuditFrequently asked questions
When were attrs and states deprecated in Odoo?
Odoo 16 deprecated the attrs and states attributes on XML view field tags. From Odoo 17 onward they are removed in practice and must be replaced with direct invisible, readonly, and required expressions.
What replaces attrs in Odoo 16+?
Each modifier becomes a standalone attribute bound to a Python-style expression. For example attrs invisible becomes invisible="state != 'draft'", evaluated against the record's field values.
What replaces the states attribute?
The states attribute, which toggled visibility by a status field, is expressed with an invisible attribute comparing the relevant state field, or handled with computed visibility on the model side.
Will my module install if it still uses attrs?
On Odoo 16 you may see warnings, and on later versions views can fail to render or the module can fail to install. Replacing attrs and states before upgrading avoids these issues.