From d0141aa5ced0626abc8d10bf819857b7337f771f Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 26 Jan 2012 10:23:04 +0100 Subject: [PATCH] [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 --- addons/web/static/src/js/search.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index ae38f7dbf25..96af74672d3 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -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