summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorMohammed Shekha (OpenERP) <msh@openerp.com>2013-12-24 19:25:26 +0530
committerMohammed Shekha (OpenERP) <msh@openerp.com>2013-12-24 19:25:26 +0530
commit1496d7a77c4e4abe321dfaa09c70a204aaa2270a (patch)
tree1d5c5d771d5c5897ae6cb5a96599eb1177b1f9d0 /addons/web/static/src
parent7bb4f6da82750fc4b90cc602adf4294ab8215f96 (diff)
parent58d17041621ccdd0acb5a130b5f15c87ca3e2727 (diff)
[FIX]Web: Refixed the issue of context propagation, we must not remove search_default and group_bys of current action context, previous fix was removing action context, improved the fix, also added pairs and object function for sake of simplicity.
bzr revid: msh@openerp.com-20131224135526-55b4cd3qyt0j5ugi
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/views.js37
1 files changed, 35 insertions, 2 deletions
diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js
index 21ff627c544..984d8d7bdfd 100644
--- a/addons/web/static/src/js/views.js
+++ b/addons/web/static/src/js/views.js
@@ -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 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
+ var ncontext = new instance.web.CompoundContext(
+ self.object(_.reject(self.pairs(dataset.get_context().eval()), function(pair) {
+ return pair[0].match('^(?:(?:default_|search_default_).+|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 || {});
@@ -1397,6 +1405,31 @@ instance.web.View = instance.web.Widget.extend({
return dataset.exec_workflow(record_id, action_data.name).then(handler);
}
},
+ // Convert an object into a list of `[key, value]` pairs.
+ pairs: function(obj) {
+ var keys = _.keys(obj);
+ var length = keys.length;
+ var pairs = new Array(length);
+ for (var i = 0; i < length; i++) {
+ pairs[i] = [keys[i], obj[keys[i]]];
+ }
+ return pairs;
+ },
+ // Converts lists into objects. Pass either a single array of `[key, value]`
+ // pairs, or two parallel arrays of the same length -- one of keys, and one of
+ // the corresponding values.
+ object: function(list, values) {
+ if (list == null) return {};
+ var result = {};
+ for (var i = 0, length = list.length; i < length; i++) {
+ if (values) {
+ result[list[i]] = values[i];
+ } else {
+ result[list[i][0]] = list[i][1];
+ }
+ }
+ return result;
+ },
/**
* Directly set a view to use instead of calling fields_view_get. This method must
* be called before start(). When an embedded view is set, underlying implementations