diff --git a/web_tree_dynamic_colored_field/README.rst b/web_tree_dynamic_colored_field/README.rst index e1b4510d..cd3242cb 100644 --- a/web_tree_dynamic_colored_field/README.rst +++ b/web_tree_dynamic_colored_field/README.rst @@ -1,5 +1,5 @@ -.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: https://www.gnu.org/licenses/agpl :alt: License: AGPL-3 ============================ @@ -99,11 +99,16 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, -help us smash it by providing a detailed and welcomed feedback. +help us smash it by providing detailed and welcomed feedback. Credits ======= +Images +------ + +* Odoo Community Association: `Icon `_. + Contributors ------------ diff --git a/web_tree_dynamic_colored_field/__init__.py b/web_tree_dynamic_colored_field/__init__.py index 8945c43c..6d4f4bde 100644 --- a/web_tree_dynamic_colored_field/__init__.py +++ b/web_tree_dynamic_colored_field/__init__.py @@ -1,2 +1 @@ -# Copyright 2015-2018 Camptocamp SA, Damien Crier # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/web_tree_dynamic_colored_field/__manifest__.py b/web_tree_dynamic_colored_field/__manifest__.py index 146c30db..13e207f1 100644 --- a/web_tree_dynamic_colored_field/__manifest__.py +++ b/web_tree_dynamic_colored_field/__manifest__.py @@ -4,7 +4,7 @@ 'name': 'Colorize field in tree views', 'summary': 'Allows you to dynamically color fields on tree views', 'category': 'Hidden/Dependency', - 'version': '11.0.1.0.1', + 'version': '12.0.1.0.0', 'depends': ['web'], 'author': "Camptocamp, Therp BV, Odoo Community Association (OCA)", 'license': 'AGPL-3', diff --git a/web_tree_dynamic_colored_field/readme/CONTRIBUTORS.rst b/web_tree_dynamic_colored_field/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..a1e31ed6 --- /dev/null +++ b/web_tree_dynamic_colored_field/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Damien Crier +* Holger Brunn +* Artem Kostyuk +* Guewen Baconnier diff --git a/web_tree_dynamic_colored_field/readme/DESCRIPTION.rst b/web_tree_dynamic_colored_field/readme/DESCRIPTION.rst new file mode 100644 index 00000000..c3f632ca --- /dev/null +++ b/web_tree_dynamic_colored_field/readme/DESCRIPTION.rst @@ -0,0 +1,15 @@ +This module aims to add support for dynamically coloring fields in tree view +according to data in the record. + +It provides attributes on fields with the similar syntax as the ``colors`` attribute +in tree tags. + +Further, it provides a ``color_field`` attribute on tree tags's ``colors`` to use +a field's value as color. + +Features +======== + +* Add attribute ``bg_color`` on field's ``options`` to color background of a cell in tree view +* Add attribute ``fg_color`` on field's ``options`` to change text color of a cell in tree view +* Add attribute ``color_field`` on the tree element's ``colors`` to use as color diff --git a/web_tree_dynamic_colored_field/readme/USAGE.rst b/web_tree_dynamic_colored_field/readme/USAGE.rst new file mode 100644 index 00000000..921a3262 --- /dev/null +++ b/web_tree_dynamic_colored_field/readme/USAGE.rst @@ -0,0 +1,67 @@ +* In the tree view declaration, put ``options='{"bg_color": "red: customer==True"}`` attribute in the ``field`` tag:: + + ... + + + ... + + ... + + + ... + + With this example, column which renders 'name' field will have its background colored in red. + +* In the tree view declaration, put ``options='{"fg_color": "white:customer == True"}'`` attribute in the ``field`` tag:: + + ... + + + ... + + ... + + + ... + + With this example, column which renders 'name' field will have its text colored in white on a customer records. + +* In the tree view declaration, use ``options='"color_field": "my_color"'`` attribute in the ``tree`` tag:: + + ... + + + ... + + ... + + + ... + +* If you want to use more than one color, you can split the attributes using ';': + +.. code:: + + options='{"fg_color": "red:red_color == True; green:green_color == True"}' + +Example: + +.. code:: xml + + ... + + + ... + + ... + + + ... + + With this example, the content of the field named `my_color` will be used to + populate the `my_color` CSS value. Use a function field to return whichever + color you want depending on the other record values. Note that this + overrides the rest of `colors` attributes, and that you need the tree + to load your field in the first place by adding it as invisible field. + +**Note that you should always use single quotes for fields' ``options`` and wrap nested values in double quotes since ``options`` is a JSON object.** diff --git a/web_tree_dynamic_colored_field/static/src/js/web_tree_dynamic_colored_field.js b/web_tree_dynamic_colored_field/static/src/js/web_tree_dynamic_colored_field.js index 334db537..b67db348 100644 --- a/web_tree_dynamic_colored_field/static/src/js/web_tree_dynamic_colored_field.js +++ b/web_tree_dynamic_colored_field/static/src/js/web_tree_dynamic_colored_field.js @@ -13,7 +13,7 @@ odoo.define('web_tree_dynamic_colored_field', function (require) { _renderBody: function () { if (this.arch.attrs.colors) { var colorAttr = this.arch.attrs.colors.split(';') - .filter(color => color.trim().startsWith('color_field')); + .filter(color >= color.trim().startsWith('color_field')); if (colorAttr.length > 0) { var colorField = colorAttr[0].split(':')[1].trim(); // validate the presence of that field in tree view @@ -90,7 +90,7 @@ odoo.define('web_tree_dynamic_colored_field', function (require) { /** * Parse `: ` forms to - * evaluatable expressions + * evaluable expressions * * @param {string} pairColor `color: expression` pair */ diff --git a/web_tree_dynamic_colored_field/views/web_tree_dynamic_colored_field.xml b/web_tree_dynamic_colored_field/views/web_tree_dynamic_colored_field.xml index ea8e1129..116b37db 100644 --- a/web_tree_dynamic_colored_field/views/web_tree_dynamic_colored_field.xml +++ b/web_tree_dynamic_colored_field/views/web_tree_dynamic_colored_field.xml @@ -2,7 +2,7 @@