From c887e53b324770982eb8420fb4cc7ec5f70074cb Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 2 Jul 2014 15:18:56 +0200 Subject: [PATCH] [FIX] web: force seession context reload when reloading client The goal is to ensure that HTTP requests done while reloading the client (e.g. the menu bar, etc.) do not use a deprecated session context. Also undo the previous fix from a0ee2b5 as it would cause other issues (e.g. prevent setting the admin password/lang when creating a new db using the db manager) This logic does not belong in the business methods of res.users. --- addons/web/static/src/js/chrome.js | 13 +++++++++++++ openerp/addons/base/res/res_users.py | 6 +----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 3534de032eb..922c3a36e47 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -679,6 +679,19 @@ instance.web.Reload = function(parent, action) { }; instance.web.client_actions.add("reload", "instance.web.Reload"); +/** + * Client action to refresh the session context (making sure + * HTTP requests will have the right one) then reload the + * whole interface. + */ +instance.web.ReloadContext = function(parent, action) { + // side-effect of get_session_info is to refresh the session context + instance.session.rpc("/web/session/get_session_info", {}).then(function() { + instance.web.Reload(parent, action); + }); +} +instance.web.client_actions.add("reload_context", "instance.web.ReloadContext"); + /** * Client action to go back in breadcrumb history. * If can't go back in history stack, will go back to home. diff --git a/openerp/addons/base/res/res_users.py b/openerp/addons/base/res/res_users.py index c57fdc447b7..00cb358c6c4 100644 --- a/openerp/addons/base/res/res_users.py +++ b/openerp/addons/base/res/res_users.py @@ -322,10 +322,6 @@ class res_users(osv.osv): if id in self._uid_cache[db]: del self._uid_cache[db][id] self.context_get.clear_cache(self) - if request: - if uid in ids and 'lang' in values: - request.session.get_context() - request.session.modified = True return res def unlink(self, cr, uid, ids, context=None): @@ -497,7 +493,7 @@ class res_users(osv.osv): def preference_save(self, cr, uid, ids, context=None): return { 'type': 'ir.actions.client', - 'tag': 'reload', + 'tag': 'reload_context', } def preference_change_password(self, cr, uid, ids, context=None):