diff options
| author | Martin Geubelle <mge@odoo.com> | 2018-03-20 11:48:06 +0100 |
|---|---|---|
| committer | Martin Geubelle <mge@odoo.com> | 2018-03-20 13:49:32 +0100 |
| commit | 75d9a2b4db9fbad00114832186b7d4e3983124ba (patch) | |
| tree | 885d621d1b04c80bfd2e23db70632edcb8622754 /addons/web/static/src | |
| parent | c3b49b3a5fec204a62c4a6741c6e7bf71c1bee55 (diff) | |
[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
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/form_widgets.js | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/addons/web/static/src/js/views/form_widgets.js b/addons/web/static/src/js/views/form_widgets.js index a074c094de8..fe1cc32955e 100644 --- a/addons/web/static/src/js/views/form_widgets.js +++ b/addons/web/static/src/js/views/form_widgets.js @@ -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); |
