[FIX] context_timestamp MUST return a "timezone aware" timestamp
This commit is contained in:
parent
8276fb5853
commit
7f88681186
|
@ -356,17 +356,16 @@ class datetime(_column):
|
||||||
else:
|
else:
|
||||||
registry = openerp.modules.registry.RegistryManager.get(cr.dbname)
|
registry = openerp.modules.registry.RegistryManager.get(cr.dbname)
|
||||||
tz_name = registry.get('res.users').read(cr, SUPERUSER_ID, uid, ['tz'])['tz']
|
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:
|
if tz_name:
|
||||||
try:
|
try:
|
||||||
utc = pytz.timezone('UTC')
|
|
||||||
context_tz = pytz.timezone(tz_name)
|
context_tz = pytz.timezone(tz_name)
|
||||||
utc_timestamp = utc.localize(timestamp, is_dst=False) # UTC = no DST
|
|
||||||
return utc_timestamp.astimezone(context_tz)
|
return utc_timestamp.astimezone(context_tz)
|
||||||
except Exception:
|
except Exception:
|
||||||
_logger.debug("failed to compute context/client-specific timestamp, "
|
_logger.debug("failed to compute context/client-specific timestamp, "
|
||||||
"using the UTC value",
|
"using the UTC value",
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
return timestamp
|
return utc_timestamp
|
||||||
|
|
||||||
class binary(_column):
|
class binary(_column):
|
||||||
_type = 'binary'
|
_type = 'binary'
|
||||||
|
|
Loading…
Reference in New Issue