[FIX] race condition on selecting saved filters

Deferreds can't "go through" al callbacks, so even when searchviews
correctly wait on this.on_clear it can't get the information on when
the other view is done clearing, and it lauches two concurrent views.

In this precise case though, there's no need to launch a search after
this clear, just want to remove all searchview state.

bzr revid: xmo@openerp.com-20120126092304-fe79ulj6txkgy411
This commit is contained in:
Xavier Morel
2012-01-26 10:23:04 +01:00
parent 1059bb758d
commit d0141aa5ce
+7 -3
View File
@@ -259,7 +259,7 @@ openerp.web.SearchView = openerp.web.OldWidget.extend(/** @lends openerp.web.Sea
val = val.slice(4);
val = parseInt(val, 10);
var filter = this.managed_filters[val];
this.do_clear().then(_.bind(function() {
this.do_clear(false).then(_.bind(function() {
select.val('get:' + val);
var groupbys = _.map(filter.context.group_by.split(","), function(el) {
return {"group_by": el};
@@ -412,7 +412,10 @@ openerp.web.SearchView = openerp.web.OldWidget.extend(/** @lends openerp.web.Sea
on_invalid: function (errors) {
this.do_notify(_t("Invalid Search"), _t("triggered from search view"));
},
do_clear: function () {
/**
* @param {Boolean} [reload_view=true]
*/
do_clear: function (reload_view) {
this.$element.find('.filter_label, .filter_icon').removeClass('enabled');
this.enabled_filters.splice(0);
var string = $('a.searchview_group_string');
@@ -427,7 +430,8 @@ openerp.web.SearchView = openerp.web.OldWidget.extend(/** @lends openerp.web.Sea
input.datewidget.set_value(false);
}
});
return $.async_when().pipe(this.on_clear);
return $.async_when().pipe(
reload_view !== false ? this.on_clear : null);
},
/**
* Triggered when the search view gets cleared