summaryrefslogtreecommitdiff
path: root/doc/reference/javascript_reference.rst
diff options
context:
space:
mode:
authoroco-odoo <oco@odoo.com>2018-06-08 15:20:49 +0200
committerGitHub <noreply@github.com>2018-06-08 15:20:49 +0200
commitd4cd8be48f83a7775c667bc6c968a4b9e14679be (patch)
tree9185c59636525a98292e31112ca00152c0db4fb3 /doc/reference/javascript_reference.rst
parenta8aa0bcbbe48babe877e08d81e5bdcc9e5779fdc (diff)
[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.
Diffstat (limited to 'doc/reference/javascript_reference.rst')
-rw-r--r--doc/reference/javascript_reference.rst28
1 files changed, 28 insertions, 0 deletions
diff --git a/doc/reference/javascript_reference.rst b/doc/reference/javascript_reference.rst
index ef41944e389..141c614f29c 100644
--- a/doc/reference/javascript_reference.rst
+++ b/doc/reference/javascript_reference.rst
@@ -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 &lt; 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
---------------------