[FIX] web: correctly display statusbar

Some status were shown in the statusbar even though they were not specified in
the `statusbar_visible` attribute. This happened when the value was a substring
of one specified value.

Example:
```
hello = fields.Selection([('hello', 'Hello'), ('hello_world', 'Hello World')])
<field name='hello' widget='statusbar' statusbar_visible='hello_world'/>
```
In this case, both status were shown ('hello' is a substring of 'hello_world').

Fixes #20034
This commit is contained in:
Martin Geubelle
2018-03-20 13:49:32 +01:00
parent c3b49b3a5f
commit 75d9a2b4db
@@ -1372,13 +1372,11 @@ var FieldStatus = common.AbstractField.extend({
// For field type selection filter values according to
// statusbar_visible attribute of the field. For example:
// statusbar_visible="draft,open".
var select = this.field.selection;
for(var i=0; i < select.length; i++) {
var key = select[i][0];
if(key === this.get('value') || !this.options.visible || this.options.visible.indexOf(key) !== -1) {
selection_unfolded.push(select[i]);
}
}
var restriction = _.isString(this.options.visible) ? this.options.visible.split(',') : [];
selection_unfolded = _.filter(this.field.selection, function (val) {
return val[0] === self.get('value') || !self.options.visible || _.contains(restriction, val[0]);
});
return $.when();
}
}, this);