[FIX] web: force seession context reload when reloading client
authorOlivier Dony <odo@openerp.com>
Wed, 2 Jul 2014 13:18:56 +0000 (15:18 +0200)
committerOlivier Dony <odo@openerp.com>
Wed, 2 Jul 2014 13:18:56 +0000 (15:18 +0200)
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
openerp/addons/base/res/res_users.py

index 3534de0..922c3a3 100644 (file)
@@ -680,6 +680,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.
  */
index c57fdc4..00cb358 100644 (file)
@@ -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):