From cdb01d52ea0a7b3b02594f2bd98d1a7bdf2fa2a3 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 1 Mar 2018 11:19:23 +0100 Subject: [FIX] web: create favorite filters in dialogs This is a manual forwardport of rev. b466b3bc608. Consider the following scenario: open in edit mode a form view containing a many2many field displayed with widget many2many_tags, on the many2many field dropdown, click on 'Search More' (it opens a dialog), and in the dialog, try to save the current search in the searchview's favorite menu. Before this rev., it crashed because it tried to retrieve the action's context (to add to the saved filter), whereas there is no action in this case. Actually, the action's context should never been used in this case. What must be used is the controller's context (this mainly makes sense for Pivot and Graph views). Fixes #23293 --- addons/web/static/src/js/chrome/abstract_web_client.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'addons/web/static/src/js/chrome/abstract_web_client.js') diff --git a/addons/web/static/src/js/chrome/abstract_web_client.js b/addons/web/static/src/js/chrome/abstract_web_client.js index b4b192c1ea9..9fe38adbde6 100644 --- a/addons/web/static/src/js/chrome/abstract_web_client.js +++ b/addons/web/static/src/js/chrome/abstract_web_client.js @@ -68,6 +68,7 @@ var AbstractWebClient = Widget.extend(ServiceProviderMixin, { .load_filters(event.data.dataset, event.data.action_id) .then(event.data.on_success); }, + create_filter: '_onCreateFilter', push_state: '_onPushState', show_effect: '_onShowEffect', // session @@ -337,6 +338,18 @@ var AbstractWebClient = Widget.extend(ServiceProviderMixin, { // Handlers //-------------------------------------------------------------------------- + /** + * @private + * @param {OdooEvent} e + * @param {Object} e.data.filter the filter description + * @param {function} e.data.on_success called when the RPC succeeds with its + * returned value as argument + */ + _onCreateFilter: function (e) { + data_manager + .create_filter(e.data.filter) + .then(e.data.on_success); + }, /** * Displays a warning in a dialog of with the NotificationManager * -- cgit v1.2.3