From 6f7031e9fb74561aa0d4630caf47987675b49a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Mon, 14 May 2018 21:18:22 +0200 Subject: [FIX] web: pass unique ids on `name_get` rpc Before this commit, when a list contains records with many2one fields that contain the same values, duplicate ids were passed to the server on rpc `name_get`. For instance, if 40 records in a list refer to a Unit of Measure with id "1" whose displayed_name is "unit(s)", the server receives a long list of ids with simply the value "1". Also, the server responds with a list of displayed_name, in this case a list of 40 strings "unit(s)". With this commit, we always pass unique ids to the server on rpc `name_get`. --- addons/web/static/src/js/views/basic/basic_model.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index d0eed4dc524..a90cc1075c9 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1974,13 +1974,16 @@ var BasicModel = AbstractModel.extend({ return this._rpc({ model: model, method: 'name_get', - args: [ids], + args: [_.uniq(ids)], context: list.context, }) .then(function (name_gets) { - for (var i = 0; i < name_gets.length; i++) { - records[i].data.display_name = name_gets[i][1]; - } + _.each(records, function (record) { + var nameGet = _.find(name_gets, function (nameGet) { + return nameGet[0] === record.data.id; + }); + record.data.display_name = nameGet[1]; + }); }); }, /** -- cgit v1.2.3