OD315 invalid-modifier¶
A view modifier is not an expression Odoo reads.
| Category | Severity | Series | Needs the index |
|---|---|---|---|
| Correctness | Error | 17.0 and later | yes |
What it reports¶
An invisible, readonly, required or column_invisible value in a view arch that is no Python
expression, or that uses a construct Odoo's validation does not read: a comprehension, a set, a
lambda, an f-string, a slice, :=, or * and ** unpacking. An <attribute> spec counts by its
text, or by its add when the separator is and or or.
The values 0, 1, true and false, in any case, and an empty value are not parsed, as in Odoo.
Odoo compares the value exactly as written, so blank <attribute> text is an empty expression and
is reported: leave the element empty to clear the modifier. A constant in an add stays a constant
only where it stands alone, so it is parsed when it joins a value the located element holds.
%(id)d, %(id)s and %% are read as the data loader rewrites them, ids first, so an id right
after a % stays unresolved and state %%%(id)d is reported: write a blank before the id, as in
state %% %(id)d. The rule reads each value alone, so it also reports this where the same id stands
free elsewhere in the arch, which lets the loader resolve it.
Why it matters¶
Odoo parses these attributes when it validates the view, so a broken one stops the install or the upgrade of the module. A demo file differs: see load failures.
The rule leaves alone a view whose root is QWeb or is not indexed, the attributes of an element
with a position and of an xpath, which locate an element, add with any other separator, and a
constant add that may stand alone. That is when the view tree cannot show that every element it
may locate holds a value, or when a spec of the tree may clear that modifier first, since the rule
cannot order the extensions of a tree. A spec counts when it clears or removes the modifier on such
an element, or when it names no element and so may reach any of them. The rule needs base in the
index.
Example¶
The expression stops after and, so the module fails to install.