From a9eb43b8355707f2aca6fb10fc7f0775e030b7db Mon Sep 17 00:00:00 2001 From: Adam Heinz Date: Fri, 11 Feb 2022 11:58:13 -0500 Subject: [PATCH] [IMP] web_tree_dynamic_colored_field: black, isort, prettier --- .../addons/web_tree_dynamic_colored_field | 1 + setup/web_tree_dynamic_colored_field/setup.py | 6 +++++ .../src/js/web_tree_dynamic_colored_field.js | 25 ++++++++++++------- 3 files changed, 23 insertions(+), 9 deletions(-) create mode 120000 setup/web_tree_dynamic_colored_field/odoo/addons/web_tree_dynamic_colored_field create mode 100644 setup/web_tree_dynamic_colored_field/setup.py diff --git a/setup/web_tree_dynamic_colored_field/odoo/addons/web_tree_dynamic_colored_field b/setup/web_tree_dynamic_colored_field/odoo/addons/web_tree_dynamic_colored_field new file mode 120000 index 000000000..33902bb25 --- /dev/null +++ b/setup/web_tree_dynamic_colored_field/odoo/addons/web_tree_dynamic_colored_field @@ -0,0 +1 @@ +../../../../web_tree_dynamic_colored_field \ No newline at end of file diff --git a/setup/web_tree_dynamic_colored_field/setup.py b/setup/web_tree_dynamic_colored_field/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/web_tree_dynamic_colored_field/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) 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 26182edf2..8998e3b6b 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,12 +13,15 @@ odoo.define("web_tree_dynamic_colored_field", function (require) { */ _renderBody: function () { if (this.arch.attrs.colors) { - var colorAttr = this.arch.attrs.colors.split(';'); + var colorAttr = this.arch.attrs.colors.split(";"); if (colorAttr.length > 0) { - var colorType = colorAttr[0].split(':')[0].trim() - var colorField = colorAttr[0].split(':')[1].trim(); - // validate the presence of that field in tree view - if (this.state.data.length && colorField in this.state.data[0].data) { + var colorType = colorAttr[0].split(":")[0].trim(); + var colorField = colorAttr[0].split(":")[1].trim(); + // Validate the presence of that field in tree view + if ( + this.state.data.length && + colorField in this.state.data[0].data + ) { if (colorType === "color_field") { this.colorField = colorField; } else if (colorType === "bg_color_field") { @@ -62,11 +65,15 @@ odoo.define("web_tree_dynamic_colored_field", function (require) { } var treeBgColor = record.data[this.bgColorField]; if (treeBgColor) { - $td.css('background-color', treeBgColor); + $td.css("background-color", treeBgColor); + } + // Apply 's own `options` + if (!node.attrs.options) { + return; + } + if (node.tag !== "field") { + return; } - // apply 's own `options` - if (!node.attrs.options) { return; } - if (node.tag !== 'field') { return; } var nodeOptions = node.attrs.options; if (!_.isObject(nodeOptions)) { nodeOptions = pyUtils.py_eval(nodeOptions);