From a32d8cb9dea8dad6168f81fc0559e0686cf1983d Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Fri, 25 Apr 2014 12:25:01 +0200 Subject: [PATCH] [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 --- addons/web_graph/static/src/js/pivot_table.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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) {