[FIX] filter user context and client specific value from res.log context
authorXavier ALT <xal@openerp.com>
Tue, 28 Feb 2012 15:25:08 +0000 (16:25 +0100)
committerXavier ALT <xal@openerp.com>
Tue, 28 Feb 2012 15:25:08 +0000 (16:25 +0100)
 - We do not want to store user context (lang, timezone) and openerp client
   specific values (bin_size, client, _terp_view_name) as those value will
   be updated anyway (depending on user/client settings) when user access
   an res.log item.

bzr revid: xal@openerp.com-20120228152508-5hjiqmezl2j6wbct

bin/addons/base/res/res_log.py

index 26e1eae..abca8b6 100644 (file)
@@ -50,7 +50,19 @@ class res_log(osv.osv):
                        self._index_name)
 
     def create(self, cr, uid, vals, context=None):
+
+        def filter_context_value(c):
+            """filter unrequired value from context"""
+            # We remove user context and web client related value as those
+            # values will be re-set when accessing res.log item, depending
+            # on user or client settings
+            if isinstance(c, dict):
+                FILTER_OUT_KEYS = ['tz', 'lang', 'client', 'bin_size', '_terp_view_name']
+                for context_key in FILTER_OUT_KEYS:
+                    c.pop(context_key, None)
+            return c
         create_context = context and dict(context) or {}
+        create_context = filter_context_value(create_context)
         if 'res_log_read' in create_context:
             vals['read'] = create_context.pop('res_log_read')
         if create_context and not vals.get('context'):