[IMP] web: add decoration support for all field widgets (#25160)
It is sometimes useful to be able to customize slightly the color of a field depending on some conditions on the current record. For example, imagine that we want to show a VAT number field in green/red, if it was validated or not. To do that, we can add a field with an onchange, and simply add decoration-danger and decoration-success attributes to the field.
This commit is contained in:
@@ -1358,6 +1358,34 @@ Let us mention the most important ones:
|
||||
- the field widgets can be used outside of a view. Their API is slightly
|
||||
awkward, but they are designed to be standalone.
|
||||
|
||||
Decorations
|
||||
-----------
|
||||
|
||||
Like the list view, field widgets have a simple support for decorations. The
|
||||
goal of decorations is to have a simple way to specify a text color depending on
|
||||
the record current state. For example,
|
||||
|
||||
.. code-block:: xml
|
||||
|
||||
<field name="state" decoration-danger="amount < 10000"/>
|
||||
|
||||
The valid decoration names are:
|
||||
|
||||
- decoration-bf
|
||||
- decoration-it
|
||||
- decoration-danger
|
||||
- decoration-info
|
||||
- decoration-muted
|
||||
- decoration-primary
|
||||
- decoration-success
|
||||
- decoration-warning
|
||||
|
||||
Each decoration *decoration-X* will be mapped to a css class *text-X*, which is
|
||||
a standard bootstrap css class (except for *text-it* and *text-bf*, which are
|
||||
handled by odoo and correspond to italic and bold, respectively). Note that the
|
||||
value of the decoration attribute should be a valid python expression, which
|
||||
will be evaluated with the record as evaluation context.
|
||||
|
||||
Non relational fields
|
||||
---------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user