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/views/view_dialogs.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'addons/web/static/src/js/views/view_dialogs.js') diff --git a/addons/web/static/src/js/views/view_dialogs.js b/addons/web/static/src/js/views/view_dialogs.js index 876c37fbd59..645540b7a57 100644 --- a/addons/web/static/src/js/views/view_dialogs.js +++ b/addons/web/static/src/js/views/view_dialogs.js @@ -238,8 +238,11 @@ var SelectCreateListController = ListController.extend({ // row of the list) such that it triggers up 'select_record' with its res_id. custom_events: _.extend({}, ListController.prototype.custom_events, { open_record: function (event) { - var selected_record = this.model.get(event.data.id); - this.trigger_up('select_record', {id: selected_record.res_id}); + var selectedRecord = this.model.get(event.data.id); + this.trigger_up('select_record', { + id: selectedRecord.res_id, + display_name: selectedRecord.data.display_name, + }); }, }), }); @@ -251,7 +254,7 @@ var SelectCreateDialog = ViewDialog.extend({ custom_events: _.extend({}, ViewDialog.prototype.custom_events, { select_record: function (event) { if (!this.options.readonly) { - this.on_selected([event.data.id]); + this.on_selected([event.data]); this.close(); } }, @@ -369,7 +372,14 @@ var SelectCreateDialog = ViewDialog.extend({ disabled: true, close: true, click: function () { - self.on_selected(self.list_controller.getSelectedIds()); + var records = self.list_controller.getSelectedRecords(); + var values = _.map(records, function (record) { + return { + id: record.res_id, + display_name: record.data.display_name, + }; + }); + self.on_selected(values); }, }); } @@ -399,7 +409,11 @@ var SelectCreateDialog = ViewDialog.extend({ var self = this; var dialog = new FormViewDialog(this, _.extend({}, this.options, { on_saved: function (record) { - self.on_selected([record.res_id]); + var values = [{ + id: record.res_id, + display_name: record.data.display_name, + }]; + self.on_selected(values); }, })).open(); dialog.on('closed', this, this.close.bind(this)); -- cgit v1.2.3