From 1f693aaed6f6e28a384f20d357f8a3f558d33f6a Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Wed, 30 Apr 2014 10:49:27 +0200 Subject: [PATCH] [FIX] fix a crash in graphview when user clicked rapidly twice on menu item The issue was that the get_search_fields method tried to get the view's corresponding searchview after a rpc (fields_get). Sadly, if the user had meanwhile clicked again on the menu item, the first view would be detached from the view manager and would be unable to reach the search view. The solution is to move the lookup for the search view in the start method, where it is guaranteed to exist. bzr revid: ged@openerp.com-20140430084927-m11dxqg9ko0dnu08 --- addons/web_graph/static/src/js/graph_widget.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/web_graph/static/src/js/graph_widget.js b/addons/web_graph/static/src/js/graph_widget.js index d6f9b929dea..84ca75ddda2 100644 --- a/addons/web_graph/static/src/js/graph_widget.js +++ b/addons/web_graph/static/src/js/graph_widget.js @@ -43,6 +43,13 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ this.$('.graph_main_content').addClass('graph_pivot_mode'); } + // get search view + var parent = this.getParent(); + while (!(parent instanceof openerp.web.ViewManager)) { + parent = parent.getParent(); + } + this.search_view = parent.searchview; + openerp.session.rpc('/web_graph/check_xlwt').then(function (result) { self.$('.graph_options_selection label').toggle(result); }); @@ -76,16 +83,9 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ // this method gets the fields that appear in the search view, under the // 'Groupby' heading get_search_fields: function () { - var self = this, - parent = this.getParent(); + var self = this; - while (!(parent instanceof openerp.web.ViewManager)) { - parent = parent.getParent(); - } - - var search_view = parent.searchview; - - var groupbygroups = _(search_view.inputs).select(function (g) { + var groupbygroups = _(this.search_view.inputs).select(function (g) { return g instanceof openerp.web.search.GroupbyGroup; });