upgrade-attrs-states (U1701)#
A view uses attrs or states, rejected since Odoo 17.0.
Applies to Odoo 17.0 and later.
What it does#
Reports attrs and states attributes in views, and <attribute name="attrs">/<attribute name="states"> in inherited views.
Why is this bad?#
Odoo 17.0 replaced them by Python expressions in invisible, readonly,
required and column_invisible: a view with attrs or states fails to
install (“Since 17.0, the “attrs” and “states” attributes are no longer
used”).
Example#
<field name="partner_id" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
<button name="action_confirm" states="draft,sent"/>
Use instead:
<field name="partner_id" readonly="state != 'draft'"/>
<button name="action_confirm" invisible="state not in ('draft', 'sent')"/>
Fix safety#
Safe for domains of =, !=, <, >, <=, >=, in and not in
terms combined with &, | and !, and for states. An existing
constant attribute is merged as Odoo 16 did: a true one wins over the
domain, a false one is replaced, and states is appended to the
invisible domain, as Odoo 16 did. A plain invisible on a list column
becomes column_invisible, which is what it meant in 16.0.
Other operators (ilike, child_of…) need a person.
<attribute name="attrs"> becomes one <attribute> per modifier, an
unsafe fix: in 16.0 the override replaced all of the parent’s attrs, in
17.0 it replaces only the modifiers it names, so a readonly the parent
had stays.