Browse Source

web_tree_dynamic_colored_field: Parse field options with pyeval

The options in <field> attributes are parsed as python expressions:
d18976d748/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.
pull/886/head
Guewen Baconnier 7 years ago
parent
commit
9394c56911
  1. 6
      web_tree_dynamic_colored_field/static/src/js/web_tree_dynamic_colored_field.js

6
web_tree_dynamic_colored_field/static/src/js/web_tree_dynamic_colored_field.js

@ -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…
Cancel
Save