summaryrefslogtreecommitdiff
path: root/addons/web_graph/static/src/js/pivot_table.js
diff options
context:
space:
mode:
authorGery Debongnie <ged@openerp.com>2014-04-25 12:25:01 +0200
committerGery Debongnie <ged@openerp.com>2014-04-25 12:25:01 +0200
commita32d8cb9dea8dad6168f81fc0559e0686cf1983d (patch)
treee7f87bc8bd9be8bd8ae104b77a068d2a143a20ba /addons/web_graph/static/src/js/pivot_table.js
parentf38fd98571898e363fcc198c477d1338bdfb4f38 (diff)
[FIX] (partially) fixes a concurrence problem in graph view
The graph view is asynchronous when updating data. It is not safe when the user tries to update quickly the group bys (for example, when adding two group bys in quick succession). This patch partially fixes the problem: it makes sure that two concurrent updates will be correctly serialized. However, it is not a complete fix: the crash can still happen when three or more updates are quickly done. A complete solution require some more work in keeping tracks of an update queue and serializing properly the updates. (will be done in trunk) bzr revid: ged@openerp.com-20140425102501-qe7ve1ug8neq1twv
Diffstat (limited to 'addons/web_graph/static/src/js/pivot_table.js')
-rw-r--r--addons/web_graph/static/src/js/pivot_table.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/addons/web_graph/static/src/js/pivot_table.js b/addons/web_graph/static/src/js/pivot_table.js
index 6b12829982e..48ae9ec3830 100644
--- a/addons/web_graph/static/src/js/pivot_table.js
+++ b/addons/web_graph/static/src/js/pivot_table.js
@@ -14,6 +14,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
this.cells = [];
this.domain = domain;
this.no_data = true;
+ this.updating = false;
this.model = model;
this.fields = fields;
this.fields.__count = {type: 'integer', string:_t('Quantity')};
@@ -55,6 +56,13 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
},
set: function (domain, row_groupby, col_groupby) {
+ var self = this;
+ if (this.updating) {
+ return this.updating.then(function () {
+ self.updating = false;
+ return self.set(domain, row_groupby,col_groupby);
+ });
+ }
var row_gb_changed = !_.isEqual(row_groupby, this.rows.groupby),
col_gb_changed = !_.isEqual(col_groupby, this.cols.groupby);
@@ -251,7 +259,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
// to null before calling update_data.
update_data: function () {
var self = this;
- return this.perform_requests().then (function () {
+ this.updating = this.perform_requests().then (function () {
var data = Array.prototype.slice.call(arguments);
self.no_data = !data[0].length;
if (self.no_data) {
@@ -273,6 +281,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
self.set_headers(row_headers, self.rows);
self.set_headers(col_headers, self.cols);
});
+ return this.updating;
},
make_headers_and_cell: function (data_pts, row_headers, col_headers, index, prefix, expand) {