From 5311db325cf62f38db906c3f769e035837e68ded Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 8 Nov 2013 17:06:27 +0100 Subject: [PATCH] [FIX] web: filter context before executing actions triggered by buttons in views bzr revid: chs@openerp.com-20131108160627-osiigir6tsr2k783 --- addons/web/static/src/js/views.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index ecdbaf8b465..6a181fc4dc7 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -1354,7 +1354,17 @@ instance.web.View = instance.web.Widget.extend({ return self.getParent().on_action_executed.apply(null, arguments); } }; - var context = new instance.web.CompoundContext(dataset.get_context(), action_data.context || {}); + var context = dataset.get_context(); + if (action_data.model !== dataset.model) { + // filter out context keys that are specific to the action model. + // Wrong default_ and search_default values will no give the expected views + // Wrong group_by values will simply fail and forbid rendering of the destination view + context = _.object(_.reject(_.pairs(context.eval()), function(pair) { + return pair[0].match('^(?:(?:default_|search_default_).+|group_by|group_by_no_leaf)$') !== null; + })); + } + + context = new instance.web.CompoundContext(context, action_data.context || {}); var handler = function (action) { if (action && action.constructor == Object) { var ncontext = new instance.web.CompoundContext(context);