[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
This commit is contained in:
parent
83221bd1f1
commit
514c63288c
|
@ -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];
|
||||
});
|
||||
},
|
||||
/**
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue