diff options
| author | Martin Trigaux <mat@openerp.com> | 2014-07-23 12:19:51 +0200 |
|---|---|---|
| committer | Martin Trigaux <mat@openerp.com> | 2014-07-23 12:31:25 +0200 |
| commit | f9d43e83c67691f84f352b2594977a05cbf3d50c (patch) | |
| tree | 222eceeff99678d4a7ab36e2b6df09d591712107 /addons/web/static/src/js/data.js | |
| parent | 9a20018166d0633c6b3cee2f13ec5c65c215df60 (diff) | |
[FIX] web: correct rev 680f955
Missing backport of commit f652402 for buffered dataset
Again, should not be forwardported
Diffstat (limited to 'addons/web/static/src/js/data.js')
| -rw-r--r-- | addons/web/static/src/js/data.js | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index ee24c481a3a..6ae69fbe67b 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -430,12 +430,30 @@ instance.web.DataSet = instance.web.Class.extend(instance.web.PropertiesMixin, read_ids: function (ids, fields, options) { if (_.isEmpty(ids)) return $.Deferred().resolve([]); - + options = options || {}; - // TODO: reorder results to match ids list - return this._model.call('read', - [ids, fields || false], - {context: this.get_context(options.context)}); + var method = 'read'; + var ids_arg = ids; + var context = this.get_context(options.context); + if (options.check_access_rule === true){ + method = 'search_read'; + ids_arg = [['id', 'in', ids]]; + context = new instance.web.CompoundContext(context, {active_test: false}); + } + return this._model.call(method, + [ids_arg, fields || false], + {context: context}) + .then(function (records) { + if (records.length <= 1) { return records; } + var indexes = {}; + for (var i = 0; i < ids.length; i++) { + indexes[ids[i]] = i; + } + records.sort(function (a, b) { + return indexes[a.id] - indexes[b.id]; + }); + return records; + }); }, /** * Read a slice of the records represented by this DataSet, based on its |
