From 75d9a2b4db9fbad00114832186b7d4e3983124ba Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Tue, 20 Mar 2018 11:48:06 +0100 Subject: [PATCH] [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')]) ``` In this case, both status were shown ('hello' is a substring of 'hello_world'). Fixes #20034 --- addons/web/static/src/js/views/form_widgets.js | 12 +++++------- 1 file 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);