From 995d08b79a43ecf64c204fe3adba92383e1c22b7 Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Wed, 14 Feb 2018 16:06:42 +0100 Subject: [PATCH] [FIX] web: factorize some `doAction` preprocessing This preprocessing also needs to be done in Studio so it's factorized in a separate function. --- .../static/src/js/chrome/action_manager.js | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/addons/web/static/src/js/chrome/action_manager.js b/addons/web/static/src/js/chrome/action_manager.js index cea75c56726..237ce1f1c96 100644 --- a/addons/web/static/src/js/chrome/action_manager.js +++ b/addons/web/static/src/js/chrome/action_manager.js @@ -172,20 +172,12 @@ var ActionManager = Widget.extend({ } return this.dp.add($.when(def)).then(function () { - action.jsID = _.uniqueId('action_'); - action.pushState = options.pushState; - // action.target 'main' is equivalent to 'current' except that it // also clears the breadcrumbs options.clear_breadcrumbs = action.target === 'main' || options.clear_breadcrumbs; - // ensure that the context and domain are evaluated - var context = new Context(self.userContext, options.additional_context, action.context); - action.context = pyeval.eval('context', context); - if (action.domain) { - action.domain = pyeval.eval('domain', action.domain, action.context); - } + self._preprocessAction(action, options); return self._handleAction(action, options); }); @@ -757,6 +749,24 @@ var ActionManager = Widget.extend({ }); return def; }, + /** + * Preprocesses the action before it is handled by the ActionManager + * (assigns a JS id, evaluates its context and domains, etc.). + * + * @param {Object} action + * @param {Object} options see @doAction options + */ + _preprocessAction: function (action, options) { + action.jsID = _.uniqueId('action_'); + action.pushState = options.pushState; + + // ensure that the context and domain are evaluated + var context = new Context(this.userContext, options.additional_context, action.context); + action.context = pyeval.eval('context', context); + if (action.domain) { + action.domain = pyeval.eval('domain', action.domain, action.context); + } + }, /** * Unlinks the given action and its controller from the internal structures * and destroys its controllers.