From 27a48f8026f824f62955d5bf2a83b2799ad98db1 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 20 Feb 2015 15:24:18 +0100 Subject: [PATCH] [FIX] web: action translation (menuitems & more menu) This rev. reverts partially 1d76586a1b0fff766581871cd277332bbfec030a This rev. is related to #3462 Regarding addons/web/controllers/main.py --- name of model ir.actions.actions is not translated it's the name of server actions, client actions and window actions that are translated. Meaning the name of the ir.actions.actions will always be in English, even when passing the user language within the context. Regarding addons/web/static/src/js/views.js --- There is no reason to pass the field values within the context of the /web/action/load call: The read methods of actions are not overidden to use the field values. Besides, it pollutes the context of the action, leading to unwanted behavior, such as the translation of the action name within the lang available in the fields of the form view (e.g. the partner form). Initially, the field values added in the context has been added within the rev. 542928adde6f74269f51d24e18896b2e8bb44fc2 Indeed, sidebar_context (or sidebar_eval_context nowadays), contains the field values, and the additional_context passed to /web/action/load is an extension of this sidebar_context. We are not sure the reasons why the sidebar_context was passed to the /web/action/load, but we believe it was to pass the session/user context containing the lang, timezone, and so on, not to pass the fields values. --- addons/web/controllers/main.py | 4 ++-- addons/web/static/src/js/views.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index f5c31b2d1bf..b3acbbe5119 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1422,7 +1422,7 @@ class Action(openerpweb.Controller): except Exception: action_id = 0 # force failed read - base_action = Actions.read([action_id], ['name', 'type'], req.session.get_context()) + base_action = Actions.read([action_id], ['type'], req.context) if base_action: ctx = {} action_type = base_action[0]['type'] @@ -1431,7 +1431,7 @@ class Action(openerpweb.Controller): ctx.update(req.context) action = req.session.model(action_type).read([action_id], False, ctx) if action: - value = clean_action(req, dict(action[0], **base_action[0])) + value = clean_action(req, action[0]) return value @openerpweb.jsonrequest diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 5fa3c8fb290..5ae8bfc79fc 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -1220,7 +1220,8 @@ instance.web.Sidebar = instance.web.Widget.extend({ sidebar_eval_context, active_ids_context)); self.rpc("/web/action/load", { action_id: item.action.id, - context: c + context: new instance.web.CompoundContext( + self.dataset.get_context(), active_ids_context).eval() }).done(function(result) { result.context = new instance.web.CompoundContext( result.context || {}, active_ids_context)