summaryrefslogtreecommitdiff
path: root/odoo/__init__.py
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2017-01-03 11:50:08 -0800
committerNicolas Lempereur <nle@odoo.com>2017-01-06 14:19:09 +0100
commit07bf7bf4f3af49f18a06000ef50ef90d8ad90224 (patch)
treec3a10087c038b931f008ed2d38fd97c0a7048825 /odoo/__init__.py
parent56c798a323d6d0fb50f3b3f66719931229913d75 (diff)
[FIX] odoo-bin: server UTC timezone on windows
On UNIX, the timezone modules conversions can be reset by using `time.tzset()`. On windows this is not available and the timezone (TZ) environment variable must be set before the first import of time module. If not, all datetime gotten in python without specifying UTC (such as datetime.datetime.now) could be wrong. This was fixed with 4a77c6a0 in 2013, but has come back since 389c2ba97b imported pkg_resources (which do a `time` module import) before that. closes #14926 opw-693764
Diffstat (limited to 'odoo/__init__.py')
-rw-r--r--odoo/__init__.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/odoo/__init__.py b/odoo/__init__.py
index a16b371ebe7..11f7a734c14 100644
--- a/odoo/__init__.py
+++ b/odoo/__init__.py
@@ -27,15 +27,12 @@ multi_process = False
#----------------------------------------------------------
# libc UTC hack
#----------------------------------------------------------
-# Make sure the OpenERP server runs in UTC. This is especially necessary
-# under Windows as under Linux it seems the real import of time is
-# sufficiently deferred so that setting the TZ environment variable
-# in odoo.cli.server was working.
+# Make sure the OpenERP server runs in UTC.
import os
-os.environ['TZ'] = 'UTC' # Set the timezone...
-import time # ... *then* import time.
-del os
-del time
+os.environ['TZ'] = 'UTC' # Set the timezone
+import time
+if hasattr(time, 'tzset'):
+ time.tzset()
#----------------------------------------------------------
# Shortcuts