[FIX] context_timestamp MUST return a "timezone aware" timestamp
authorSamus CTO <cto@openerp.com>
Wed, 13 Aug 2014 12:43:53 +0000 (14:43 +0200)
committerSamus CTO <cto@openerp.com>
Wed, 13 Aug 2014 12:58:55 +0000 (14:58 +0200)
openerp/osv/fields.py

index 040548e..ee0ea8f 100644 (file)
@@ -356,17 +356,16 @@ class datetime(_column):
         else:
             registry = openerp.modules.registry.RegistryManager.get(cr.dbname)
             tz_name = registry.get('res.users').read(cr, SUPERUSER_ID, uid, ['tz'])['tz']
+        utc_timestamp = pytz.utc.localize(timestamp, is_dst=False) # UTC = no DST
         if tz_name:
             try:
-                utc = pytz.timezone('UTC')
                 context_tz = pytz.timezone(tz_name)
-                utc_timestamp = utc.localize(timestamp, is_dst=False) # UTC = no DST
                 return utc_timestamp.astimezone(context_tz)
             except Exception:
                 _logger.debug("failed to compute context/client-specific timestamp, "
                               "using the UTC value",
                               exc_info=True)
-        return timestamp
+        return utc_timestamp
 
 class binary(_column):
     _type = 'binary'