OD305 attrs-states-removed¶
attrs and states are removed; use invisible, readonly and required expressions.
| Category | Severity | Series | Needs the index |
|---|---|---|---|
| Deprecation | Error | 17.0 and later | no |
What it reports¶
An element of a view's arch that carries an attrs or states attribute, and an
<attribute name="attrs"> or <attribute name="states"> spec in an inherited view that sets one.
Why it matters¶
Odoo 17.0 dropped both attributes. Each modifier is now its own attribute holding a Python
expression on the record's fields: invisible, readonly, required and column_invisible.
Odoo checks every view it loads for the old ones and stops the install with Since 17.0, the
"attrs" and "states" attributes are no longer used. A module ported from 16.0 without rewriting
its views cannot be installed at all. A demo file differs: see
load failures.
A states attribute on a button listed the states that show it, so states="draft,sent" becomes
invisible="state not in ('draft', 'sent')". Modules of 16.0 and earlier are not checked, since
the attributes are the only way to write modifiers there.
Example¶
<field name="payment_term_id" position="after">
<field name="client_order_ref" attrs="{'required': [('state', '=', 'sale')]}"/>
</field>
Odoo 17.0 and later refuse the view; the domain becomes a Python expression in required.
<field name="payment_term_id" position="after">
<field name="client_order_ref" required="state == 'sale'"/>
</field>