summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/chrome/action_manager_act_window.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2018-03-01 11:19:23 +0100
committerAaron Bohy <aab@odoo.com>2018-03-06 09:12:21 +0100
commitcdb01d52ea0a7b3b02594f2bd98d1a7bdf2fa2a3 (patch)
treed2969057a9670a18b5c0f1ca5e9de5a1e4b91c15 /addons/web/static/src/js/chrome/action_manager_act_window.js
parentbc66da2dfaf399f642836256c67a65a5468cd47a (diff)
[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
Diffstat (limited to 'addons/web/static/src/js/chrome/action_manager_act_window.js')
-rw-r--r--addons/web/static/src/js/chrome/action_manager_act_window.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/addons/web/static/src/js/chrome/action_manager_act_window.js b/addons/web/static/src/js/chrome/action_manager_act_window.js
index 9cfa99a9e7d..6cc05ebc5d2 100644
--- a/addons/web/static/src/js/chrome/action_manager_act_window.js
+++ b/addons/web/static/src/js/chrome/action_manager_act_window.js
@@ -21,6 +21,7 @@ ActionManager.include({
custom_events: _.extend({}, ActionManager.prototype.custom_events, {
env_updated: '_onEnvUpdated',
execute_action: '_onExecuteAction',
+ get_controller_context: '_onGetControllerContext',
search: '_onSearch',
switch_view: '_onSwitchView',
}),
@@ -716,6 +717,20 @@ ActionManager.include({
});
},
/**
+ * Handles a context request: provides to the caller the context of the
+ * current controller.
+ *
+ * @private
+ * @param {OdooEvent} ev
+ * @param {function} ev.data.callback used to send the requested context
+ */
+ _onGetControllerContext: function (ev) {
+ ev.stopPropagation();
+ var currentController = this.getCurrentController();
+ var context = currentController && currentController.widget.getContext();
+ ev.data.callback(context || {});
+ },
+ /**
* Called when there is a change in the search view, so the current action's
* environment needs to be updated with the new domain, context and groupby.
*