Browse Source

web_tree_dynamic_colored_field: Assume that color may not start with 'color_field'

The index at 0 in the following code:
  var colorField = this.arch.attrs.colors.split(';')
  .filter(color => color.trim().startsWith('color_field'))[0]
Was failing on such valid xml:
  <tree string="Buffer monitor"
        colors="red:procure_recommended_qty &gt; 0">
pull/886/head
Guewen Baconnier 7 years ago
parent
commit
9e99022497
  1. 9
      web_tree_dynamic_colored_field/static/src/js/web_tree_dynamic_colored_field.js

9
web_tree_dynamic_colored_field/static/src/js/web_tree_dynamic_colored_field.js

@ -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();
},
/**

Loading…
Cancel
Save