From 89ad23bc2d2a1c6f2f0f0e80817a575353708631 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur <nle@odoo.com> Date: Thu, 4 May 2017 14:22:04 +0200 Subject: [PATCH] [FIX] web: auto_search false and search view By default auto_search is set to `True` on window actions, this mean that for example on a list or kanban view the records will be searched on the view opening without any user action needed. Setting it to `False` disable this. Doing this had two drawbacks: - depending on race condition, the view could be displayed before the search view was loaded, - the code expected `active_search` to be present which was not the case in this instance. Before 151c9074 the second issue would not happen (active_search was set directly resolved if a search was not to be done) and this commit also wait for the search view being ready before showing the view. opw-741186 opw-741546 closes #16805 --- addons/web/static/src/js/view_manager.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/view_manager.js b/addons/web/static/src/js/view_manager.js index d23d68d0f930..78399dd4a7dc 100644 --- a/addons/web/static/src/js/view_manager.js +++ b/addons/web/static/src/js/view_manager.js @@ -149,16 +149,22 @@ var ViewManager = Widget.extend(ControlPanelMixin, { view.created = this.create_view.bind(this)(view, view_options); } + this.active_search = $.Deferred(); // Call do_search on the searchview to compute domains, contexts and groupbys if (this.search_view_loaded && this.flags.auto_search && view.controller.searchable !== false) { - this.active_search = $.Deferred(); $.when(this.search_view_loaded, view.created).done(function() { self.searchview.do_search(); }); + } else { + this.active_search.resolve(); } - var switched = $.when(view.created, this.active_search).then(function () { + var switched = $.when( + view.created, + this.search_view_loaded, + this.active_search + ).then(function () { return self._display_view(view_options, old_view).then(function () { self.trigger('switch_mode', view_type, no_store, view_options); }); -- GitLab