|
|
@ -12,10 +12,10 @@ 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(); |
|
|
|
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; } |
|
|
@ -28,6 +28,7 @@ odoo.define('web_tree_dynamic_colored_field', function (require) { |
|
|
|
this.colorField = colorField; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return this._super(); |
|
|
|
}, |
|
|
|
/** |
|
|
@ -56,7 +57,11 @@ odoo.define('web_tree_dynamic_colored_field', function (require) { |
|
|
|
} |
|
|
|
// apply <field>'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); |
|
|
|
}, |
|
|
|