[FIX] view: avoid propagation of context while executing an action

As the action could lead to unrelated model, keeping the defaults, groupby and ref do not make sense.
Backport of saas-2 revision 3872, 3891, 3892, 3893 and 3905

lp bug: https://launchpad.net/bugs/1101840 fixed
lp bug: https://launchpad.net/bugs/1263888 fixed

bzr revid: mat@openerp.com-20140425120002-g4126s9it705hwj5
This commit is contained in:
Martin Trigaux 2014-04-25 14:00:02 +02:00
commit d1c2667262
1 changed files with 10 additions and 2 deletions

View File

@ -1348,12 +1348,20 @@ instance.web.View = instance.web.Widget.extend({
var context = new instance.web.CompoundContext(dataset.get_context(), action_data.context || {});
var handler = function (action) {
if (action && action.constructor == Object) {
var ncontext = new instance.web.CompoundContext(context);
// filter out context keys that are specific to the current action.
// Wrong default_* and search_default_* values will no give the expected result
// Wrong group_by values will simply fail and forbid rendering of the destination view
var ncontext = new instance.web.CompoundContext(
_.object(_.reject(_.pairs(dataset.get_context().eval()), function(pair) {
return pair[0].match('^(?:(?:default_|search_default_).+|.+_view_ref|group_by|group_by_no_leaf|active_id|active_ids)$') !== null;
}))
);
ncontext.add(action_data.context || {});
ncontext.add({active_model: dataset.model});
if (record_id) {
ncontext.add({
active_id: record_id,
active_ids: [record_id],
active_model: dataset.model
});
}
ncontext.add(action.context || {});