From 514c63288c7d5d88d764b44696c5e3a5fc148dfb Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 22 Mar 2012 15:25:40 +0100 Subject: [PATCH] [FIX] change dataset.read_index to be implemented in terms of dataset.read_ids, not in terms of model.first() as not all model data is kept/transferred (filters are not bubbled?) bzr revid: xmo@openerp.com-20120322142540-x3j9p7kub2px6p6v --- addons/web/static/src/js/data.js | 9 +++------ addons/web/static/test/fulltest/dataset.js | 14 ++++++-------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 0dc60c0e031..b3ed5b08280 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -623,12 +623,9 @@ openerp.web.DataSet = openerp.web.OldWidget.extend( /** @lends openerp.web.Data */ read_index: function (fields, options) { options = options || {}; - // not very good - return this._model.query(fields) - .context(options.context) - .offset(this.index).first().pipe(function (record) { - if (!record) { return $.Deferred().reject().promise(); } - return record; + return this.read_ids([this.ids[this.index]], fields, options).pipe(function (records) { + if (_.isEmpty(records)) { return $.Deferred().reject().promise(); } + return records[0]; }); }, /** diff --git a/addons/web/static/test/fulltest/dataset.js b/addons/web/static/test/fulltest/dataset.js index 1b09bb7dc79..9f7ab101869 100644 --- a/addons/web/static/test/fulltest/dataset.js +++ b/addons/web/static/test/fulltest/dataset.js @@ -11,17 +11,15 @@ $(document).ready(function () { ds.ids = [10, 20, 30, 40, 50]; ds.index = 2; t.expect(ds.read_index(['a', 'b', 'c']), function (result) { - strictEqual(result.method, 'search'); + strictEqual(result.method, 'read'); strictEqual(result.model, 'some.model'); - strictEqual(result.args.length, 5); - deepEqual(result.args[0], []); - strictEqual(result.args[1], 2); - strictEqual(result.args[2], 1); - strictEqual(result.args[3], false); - deepEqual(result.args[4], context_()); + strictEqual(result.args.length, 2); + deepEqual(result.args[0], [30]); - ok(_.isEmpty(result.kwargs)); + deepEqual(result.kwargs, { + context: context_() + }); }); }); t.test('default_get', function (openerp) {