summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2018-04-24 15:03:27 +0200
committerAdrien Dieudonné <adr@odoo.com>2018-04-25 09:11:10 +0200
commit7b6744ecb78106bca3daa23d4ded490c43479703 (patch)
tree9b6b9e561cd079640480ff60f1c230f9ecac50c9 /addons/web/static/src/js
parente6e07ec1a3d8c5b9c64dac053f45d808b29fca28 (diff)
[FIX] web: pivot race condition load data
When doing several grouping quickly (or if the system is slow) on the pivot view, we may try to display data that now doesn't corresponds to the current selected groupBys. This commit ensures that when we load data of the pivot view, we drop the previous data loading that are currently being carried out. Without the fix, the added test failed with: TypeError: Cannot read property 'length' of undefined because the test does: - select one level of group by - select two levels of group by - resolve the first level of group by - resolve the second level of group by Without the fix, we would try to display the data for one level of group by when the pivot view had two levels selected. With the fix, displaying the first level of group by was discarded once a second one was being requested. opw-1825892 closes #24396
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/views/pivot/pivot_model.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/addons/web/static/src/js/views/pivot/pivot_model.js b/addons/web/static/src/js/views/pivot/pivot_model.js
index 6eddd44ffe7..76e22c8b4e5 100644
--- a/addons/web/static/src/js/views/pivot/pivot_model.js
+++ b/addons/web/static/src/js/views/pivot/pivot_model.js
@@ -17,6 +17,7 @@ odoo.define('web.PivotModel', function (require) {
*/
var AbstractModel = require('web.AbstractModel');
+var concurrency = require('web.concurrency');
var core = require('web.core');
var session = require('web.session');
var utils = require('web.utils');
@@ -32,6 +33,7 @@ var PivotModel = AbstractModel.extend({
this._super.apply(this, arguments);
this.numbering = {};
this.data = null;
+ this._loadDataDropPrevious = new concurrency.DropPrevious();
},
//--------------------------------------------------------------------------
@@ -532,7 +534,7 @@ var PivotModel = AbstractModel.extend({
}
}
- return $.when.apply(null, groupBys.map(function (groupBy) {
+ return this._loadDataDropPrevious.add($.when.apply(null, groupBys.map(function (groupBy) {
return self._rpc({
model: self.modelName,
method: 'read_group',
@@ -542,7 +544,7 @@ var PivotModel = AbstractModel.extend({
groupBy: groupBy,
lazy: false,
});
- })).then(function () {
+ }))).then(function () {
var data = Array.prototype.slice.call(arguments);
if (data[0][0].__count === 0) {
self.data.has_data = false;