[FIX] context_timestamp MUST return a "timezone aware" timestamp

This commit is contained in:
Samus CTO 2014-08-13 14:43:53 +02:00
parent 8276fb5853
commit 7f88681186
1 changed files with 2 additions and 3 deletions

View 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'