diff --git a/web_tree_dynamic_colored_field/README.rst b/web_tree_dynamic_colored_field/README.rst
index d661197cb..2b647f420 100644
--- a/web_tree_dynamic_colored_field/README.rst
+++ b/web_tree_dynamic_colored_field/README.rst
@@ -25,13 +25,13 @@ Features
Usage
=====
-* In the tree view declaration, put ``options='"bg_color": "red: customer==True"`` attribute in the ``field`` tag::
+* In the tree view declaration, put ``options='{"bg_color": "red: customer==True"}`` attribute in the ``field`` tag::
...
...
-
+
...
@@ -39,13 +39,13 @@ Usage
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::
+* In the tree view declaration, put ``options='{"fg_color": "white:customer == True"}'`` attribute in the ``field`` tag::
...
...
-
+
...
@@ -90,6 +90,7 @@ Contributors
* Damien Crier
* Holger Brunn
* Artem Kostyuk
+* Guewen Baconnier
Maintainer
----------
diff --git a/web_tree_dynamic_colored_field/__manifest__.py b/web_tree_dynamic_colored_field/__manifest__.py
index 665310b81..146c30dbe 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.0',
+ 'version': '11.0.1.0.1',
'depends': ['web'],
'author': "Camptocamp, Therp BV, Odoo Community Association (OCA)",
'license': 'AGPL-3',
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 2a96aba66..d9e14c11c 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
@@ -12,20 +12,21 @@ odoo.define('web_tree_dynamic_colored_field', function (require) {
*/
_renderBody: function () {
if (this.arch.attrs.colors) {
- var colorField = this.arch.attrs.colors.split(';')
- .filter(color => color.trim().startsWith('color_field'))[0]
- .split(':')[1]
- .trim();
- // validate the presence of that field in tree view
- var fieldNames = _(this.columns).map(
- (value) => { return value.attrs.name; }
- );
- if (fieldNames.indexOf(colorField) === -1) {
- console.warn(
- "No field named '" + colorField + "' present in view."
+ var colorAttr = this.arch.attrs.colors.split(';')
+ .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
+ var fieldNames = _(this.columns).map(
+ (value) => { return value.attrs.name; }
);
- } else {
- this.colorField = colorField;
+ if (fieldNames.indexOf(colorField) === -1) {
+ console.warn(
+ "No field named '" + colorField + "' present in view."
+ );
+ } else {
+ this.colorField = colorField;
+ }
}
}
return this._super();
@@ -56,7 +57,11 @@ odoo.define('web_tree_dynamic_colored_field', function (require) {
}
// apply 's own `options`
if (!node.attrs.options) { return; }
- var nodeOptions = JSON.parse(node.attrs.options);
+ if (node.tag !== 'field') { return; }
+ var nodeOptions = node.attrs.options;
+ if (!_.isObject(nodeOptions)) {
+ nodeOptions = pyeval.py_eval(nodeOptions);
+ }
this.applyColorizeHelper($td, nodeOptions, node, 'fg_color', 'color', ctx);
this.applyColorizeHelper($td, nodeOptions, node, 'bg_color', 'background-color', ctx);
},