[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
This commit is contained in:
Gery Debongnie 2014-04-30 10:49:27 +02:00
parent 36e3aac85e
commit 1f693aaed6
1 changed files with 9 additions and 9 deletions

View File

@ -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;
});