diff options
| author | Alexandre Kühn <aku@odoo.com> | 2018-05-14 21:18:22 +0200 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2018-05-18 17:30:34 +0200 |
| commit | 6f7031e9fb74561aa0d4630caf47987675b49a65 (patch) | |
| tree | 62630e44e49043a2ac8eba5339b8fd5fdb4cc775 /addons/web/static/src | |
| parent | 9d1083829f006df9fbe81328c5c6d35487522e84 (diff) | |
[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`.
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 11 |
1 files changed, 7 insertions, 4 deletions
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]; + }); }); }, /** |
