mirror of https://github.com/OCA/web.git
web_tree_dynamic_colored_field: Parse field options with pyeval
The options in <field> attributes are parsed as python expressions:pull/3107/headd18976d748/addons/web/static/src/js/services/data_manager.js (L273)
And the options in <button> are parsed as json...d18976d748/addons/web/static/src/js/services/data_manager.js (L411)
This code only support the <field> element because I'm not sure there is a use for the <button> element.
parent
05d9eb164a
commit
bfa57404ed
|
@ -56,7 +56,11 @@ odoo.define('web_tree_dynamic_colored_field', function (require) {
|
||||||
}
|
}
|
||||||
// apply <field>'s own `options`
|
// apply <field>'s own `options`
|
||||||
if (!node.attrs.options) { return; }
|
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, 'fg_color', 'color', ctx);
|
||||||
this.applyColorizeHelper($td, nodeOptions, node, 'bg_color', 'background-color', ctx);
|
this.applyColorizeHelper($td, nodeOptions, node, 'bg_color', 'background-color', ctx);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue