summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2012-11-26 15:05:25 +0100
committerXavier Morel <xmo@openerp.com>2012-11-26 15:05:25 +0100
commit4a5cb1ebc478cb650a2bf33081f101e4f74bc6fe (patch)
treed439fb62effd89c2e31f9bf238c024e6b36625b2 /addons/web/static/src/js
parenteb9a1c7d55bf4b07b5e516698a3b96a3f9f43d5b (diff)
[REM] EVALPOCALYPSE PART 2: no more python-side eval
trigger an error if a nonliteral context is pushed to the server (through a new object_hook) bzr revid: xmo@openerp.com-20121126140525-ni2x5m56upss610b
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/chrome.js7
-rw-r--r--addons/web/static/src/js/view_tree.js8
-rw-r--r--addons/web/static/src/js/views.js14
3 files changed, 22 insertions, 7 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index 2cca57f0b56..77d23d8fa53 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -1191,11 +1191,12 @@ instance.web.WebClient = instance.web.Client.extend({
var self = this;
return this.rpc("/web/action/load", { action_id: options.action_id })
.then(function (result) {
- var action = result;
if (options.needaction) {
- action.context.search_default_message_unread = true;
+ result.context = new instance.web.CompoundContext(
+ result.context,
+ {search_default_message_unread: true});
}
- return $.when(self.action_manager.do_action(action, {
+ return $.when(self.action_manager.do_action(result, {
clear_breadcrumbs: true,
action_menu_id: self.menu.current_menu,
})).fail(function() {
diff --git a/addons/web/static/src/js/view_tree.js b/addons/web/static/src/js/view_tree.js
index 8fd3b25ade5..4d08da385fd 100644
--- a/addons/web/static/src/js/view_tree.js
+++ b/addons/web/static/src/js/view_tree.js
@@ -44,7 +44,8 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
view_id: this.view_id,
view_type: "tree",
toolbar: this.view_manager ? !!this.view_manager.sidebar : false,
- context: this.dataset.get_context()
+ context: instance.web.pyeval.eval(
+ 'context', this.dataset.get_context())
}).done(this.on_loaded);
},
/**
@@ -227,8 +228,9 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
return this.rpc('/web/treeview/action', {
id: id,
model: this.dataset.model,
- context: new instance.web.CompoundContext(
- this.dataset.get_context(), local_context)
+ context: instance.web.pyeval.eval(
+ 'context', new instance.web.CompoundContext(
+ this.dataset.get_context(), local_context))
}).then(function (actions) {
if (!actions.length) { return; }
var action = actions[0][2];
diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js
index efd5f890544..9fad16a58b0 100644
--- a/addons/web/static/src/js/views.js
+++ b/addons/web/static/src/js/views.js
@@ -265,6 +265,17 @@ instance.web.ActionManager = instance.web.Widget.extend({
return self.do_action(result, options);
});
}
+
+ // Ensure context & domain are evaluated and can be manipulated/used
+ if (action.context) {
+ action.context = instance.web.pyeval.eval(
+ 'context', action.context);
+ }
+ if (action.domain) {
+ action.domain = instance.web.pyeval.eval(
+ 'domain', action.domain);
+ }
+
if (!action.type) {
console.error("No type for action", action);
return $.Deferred().reject();
@@ -1081,7 +1092,8 @@ instance.web.Sidebar = instance.web.Widget.extend({
context: instance.web.pyeval.eval(
'context', additional_context)
}).done(function(result) {
- result.context = _.extend(result.context || {},
+ result.context = new instance.web.CompoundContext(
+ result.context,
additional_context);
result.flags = result.flags || {};
result.flags.new_window = true;