From cc4b2bbb2729077eea4dde9282eb696ce83188d4 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Thu, 21 Mar 2013 17:11:23 +0100 Subject: [PATCH] [IMP] view_form: fix FieldStatus bzr revid: chm@openerp.com-20130321161123-j2qc2ynchneibf1o --- addons/web/static/src/js/view_form.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 28c31b80dd6..4f5d2e1cc47 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -5306,8 +5306,7 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ }, calc_domain: function() { var d = instance.web.pyeval.eval('domain', this.build_domain()); - this.set("evaluated_selection_domain", ['&', ['fold', '=', false], '|', ['id', '=', this.get('value')]].concat(d)); - this.set("evaluated_selection_domain_folded", ['&', ['fold', '!=', false], '|', ['id', '=', this.get('value')]].concat(d)); + this.set("evaluated_selection_domain", ['|', ['id', '=', this.get('value')]].concat(d)); }, /** Get the selection and render it * selection: [[identifier, value_to_display], ...] @@ -5321,19 +5320,16 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ var calculation = _.bind(function() { if (this.field.type == "many2one") { - var ds_unfold = new instance.web.DataSetSearch(self, self.field.relation, self.build_context(), this.get("evaluated_selection_domain")) - .read_slice(['name'], {}).then(function (records) { + return new instance.web.DataSetSearch(self, self.field.relation, self.build_context(), this.get("evaluated_selection_domain")) + .read_slice(['name', 'fold'], {}).then(function (records) { _.each(records, function (record) { - selection_unfolded.push([record.id, record.name]); + if (record.fold) { + selection_folded.push([record.id, record.name]); + } else { + selection_unfolded.push([record.id, record.name]); + } }); }); - var ds_fold = new instance.web.DataSetSearch(self, self.field.relation, self.build_context(), this.get("evaluated_selection_domain_folded")) - .read_slice(['name'], {}).then(function (records) { - _.each(records, function (record) { - selection_folded.push([record.id, record.name]); - }); - }); - return $.when(ds_unfold, ds_fold); } else { // For field type selection filter values according to // statusbar_visible attribute of the field. For example: