diff options
| author | Géry Debongnie <ged@odoo.com> | 2016-04-20 15:25:15 +0200 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2016-04-20 17:20:25 +0200 |
| commit | ab8a93c85268a4d7fc0bef10c0f39fb25d1530c6 (patch) | |
| tree | 611cc916b1128cf153a4604fb5c80011ffe7bb33 | |
| parent | b893342007ed8d3795ff50b75d840ef5195356b4 (diff) | |
[FIX] web: fix dataset to avoid race conditions
The read_slice method in dataset is problematic, because it alters the
dataset ids. So, if 2 consecutive read_slice are started, but the first
one ends after the second one, we don't have the correct ids in the
dataset.
This commit just make sure that previous read_slice do not alter the ids
of the next read_slice.
| -rw-r--r-- | addons/web/static/src/js/framework/data.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/addons/web/static/src/js/framework/data.js b/addons/web/static/src/js/framework/data.js index a1b8e1602e9..3e9396a4e96 100644 --- a/addons/web/static/src/js/framework/data.js +++ b/addons/web/static/src/js/framework/data.js @@ -320,6 +320,7 @@ var DataSet = Class.extend(mixins.PropertiesMixin, { this.index = null; this._sort = []; this._model = new Model(model, context); + this.orderer = new utils.DropMisordered(); }, previous: function () { this.index -= 1; @@ -408,10 +409,11 @@ var DataSet = Class.extend(mixins.PropertiesMixin, { read_slice: function (fields, options) { var self = this; options = options || {}; - return this._model.query(fields) + var query = this._model.query(fields) .limit(options.limit || false) .offset(options.offset || 0) - .all().done(function (records) { + .all(); + return this.orderer.add(query).done(function (records) { self.ids = _(records).pluck('id'); }); }, |
