From 917ba745ea188a622279b8e51723d6d3b8815535 Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Tue, 12 Sep 2017 14:25:03 +0200 Subject: [FIX] web, account: display partner in reconciliation When selecting a partner in the reconciliation widget, using the SelectCreateDialog (Search More), the partner wasn't correctly displayed. This was due to a difference between the change format of the many2one ; when using the dialog, only the `id` is sent (while the `id` and `display_name` are sent when using the many2one dropdown). These two behaviours are now standardized and both now send `id` and `display_name`. It has the advantage of sparing some `name_get`s called by the model because the `display_name` was missing. This change implies some refactoring where the SelectCreateDialog was used. --- addons/web/static/src/js/fields/relational_fields.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'addons/web/static/src/js/fields/relational_fields.js') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 9b1e930cef3..c2bd4f5d5b8 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -401,8 +401,8 @@ var FieldMany2One = AbstractField.extend({ initial_ids: ids ? _.map(ids, function (x) { return x[0]; }) : undefined, initial_view: view, disable_multiple_selection: true, - on_selected: function (element_ids) { - self.reinitialize({id: element_ids[0]}); + on_selected: function (records) { + self.reinitialize(records[0]); self.activate(); } })).open(); @@ -1150,15 +1150,16 @@ var FieldMany2Many = FieldX2Many.extend({ title: _t("Add: ") + this.string, no_create: this.nodeOptions.no_create || !this.activeActions.create, fields_view: this.attrs.views.form, - on_selected: function (res_ids) { - var new_ids = _.difference(res_ids, self.value.res_ids); - if (new_ids.length) { - var values = _.map(new_ids, function (id) { + on_selected: function (records) { + var resIDs = _.pluck(records, 'id'); + var newIDs = _.difference(resIDs, self.value.res_ids); + if (newIDs.length) { + var values = _.map(newIDs, function (id) { return {id: id}; }); self._setValue({ operation: 'ADD_M2M', - ids: values + ids: values, }); } } -- cgit v1.2.3