[FIX] res.log: make sure create context size if not bigger that field size
authorXavier ALT <xal@openerp.com>
Wed, 29 Feb 2012 11:36:09 +0000 (12:36 +0100)
committerXavier ALT <xal@openerp.com>
Wed, 29 Feb 2012 11:36:09 +0000 (12:36 +0100)
bzr revid: xal@openerp.com-20120229113609-7jjsv660j5y61mg9

bin/addons/base/res/res_log.py

index abca8b6..3012460 100644 (file)
@@ -62,11 +62,17 @@ class res_log(osv.osv):
                     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'):
             vals['context'] = create_context
+        log_context = filter_context_value(vals.get('context',{}))
+        if len(str(log_context)) > 250:
+            # if context is still bigger that field size, better lose the
+            # context completly instead of breaking later when user access
+            # res.log item
+            log_context = "{}"
+        vals['context'] = log_context
         return super(res_log, self).create(cr, uid, vals, context=context)
 
     # TODO: do not return secondary log if same object than in the model (but unlink it)