diff --git a/CHANGELOG b/CHANGELOG index b26f43d5ca..dfb192df84 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Force UTC as timezone (migration script available on tryton-tools) * Add relation_field for many2one Version 3.0.0 - 2013-10-21 diff --git a/doc/topics/install.rst b/doc/topics/install.rst index 00d91ce953..8ea75e368e 100644 --- a/doc/topics/install.rst +++ b/doc/topics/install.rst @@ -17,7 +17,6 @@ Prerequisites * Optional: MySQL-python (http://sourceforge.net/projects/mysql-python/) * Optional: pywebdav 0.9.8 or later (http://code.google.com/p/pywebdav/) * Optional: pydot (http://code.google.com/p/pydot/) - * Optional: pytz (http://pytz.sourceforge.net/) * Optional: unoconv http://dag.wieers.com/home-made/unoconv/) * Optional: sphinx (http://sphinx.pocoo.org/) * Optional: simplejson (http://undefined.org/python/#simplejson) diff --git a/etc/trytond.conf b/etc/trytond.conf index 6208dd5e33..f70a6d6168 100644 --- a/etc/trytond.conf +++ b/etc/trytond.conf @@ -86,6 +86,3 @@ jsonrpc = localhost:8000 # Default language code # language = en_US - -# Timezone of the server -# timezone = False diff --git a/setup.py b/setup.py index d13df20c57..f3823d7832 100644 --- a/setup.py +++ b/setup.py @@ -70,7 +70,6 @@ setup(name=PACKAGE, 'WebDAV': ['PyWebDAV >= 0.9.8'], 'unoconv': ['unoconv'], 'graphviz': ['pydot'], - 'timezone': ['pytz'], 'simplejson': ['simplejson'], 'cdecimal': ['cdecimal'], 'Levenshtein': ['python-Levenshtein'], diff --git a/trytond/__init__.py b/trytond/__init__.py index 6fb585c16a..80f6ae644d 100644 --- a/trytond/__init__.py +++ b/trytond/__init__.py @@ -1,5 +1,12 @@ #This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. +import os +import time + from . import server __all__ = ['server'] + +os.environ['TZ'] = 'UTC' +if hasattr(time, 'tzset'): + time.tzset() diff --git a/trytond/config.py b/trytond/config.py index 417ea584f2..ba67332c16 100644 --- a/trytond/config.py +++ b/trytond/config.py @@ -11,7 +11,6 @@ except ImportError: sys.modules['cdecimal'] = decimal import os import ConfigParser -import time import getpass import socket @@ -84,15 +83,9 @@ class ConfigManager(object): 'unoconv': 'pipe,name=trytond;urp;StarOffice.ComponentContext', 'retry': 5, 'language': 'en_US', - 'timezone': time.tzname[0] or time.tzname[1], } self.configfile = None - def set_timezone(self): - os.environ['TZ'] = self.get('timezone') - if hasattr(time, 'tzset'): - time.tzset() - def update_cmdline(self, cmdline_options): self.options.update(cmdline_options) diff --git a/trytond/ir/date.py b/trytond/ir/date.py index 2af7467805..fabf04a32c 100644 --- a/trytond/ir/date.py +++ b/trytond/ir/date.py @@ -22,8 +22,8 @@ class Date(Model): }) @staticmethod - def today(): + def today(timezone=None): ''' Return the current date ''' - return datetime.date.today() + return datetime.datetime.now(timezone).date() diff --git a/trytond/protocols/dispatcher.py b/trytond/protocols/dispatcher.py index 61bd7dadc0..f379455007 100644 --- a/trytond/protocols/dispatcher.py +++ b/trytond/protocols/dispatcher.py @@ -56,8 +56,6 @@ def dispatch(host, port, protocol, database_name, user, session, object_type, return True elif method == 'version': return VERSION - elif method == 'timezone_get': - return CONFIG['timezone'] elif method == 'list_lang': return [ ('bg_BG', 'Български'), diff --git a/trytond/res/user.py b/trytond/res/user.py index 102ba48718..db829105b2 100644 --- a/trytond/res/user.py +++ b/trytond/res/user.py @@ -23,13 +23,6 @@ from ..config import CONFIG from ..pyson import PYSONEncoder from ..rpc import RPC -try: - import pytz - TIMEZONES = [(x, x) for x in pytz.common_timezones] -except ImportError: - TIMEZONES = [] -TIMEZONES += [(None, '')] - __all__ = [ 'User', 'LoginAttempt', 'UserAction', 'UserGroup', 'Warning_', 'UserConfigStart', 'UserConfig', @@ -61,7 +54,6 @@ class User(ModelSQL, ModelView): ]) language_direction = fields.Function(fields.Char('Language Direction'), 'get_language_direction') - timezone = fields.Selection(TIMEZONES, 'Timezone', translate=False) email = fields.Char('Email') status_bar = fields.Function(fields.Char('Status Bar'), 'get_status_bar') warnings = fields.One2Many('res.user.warning', 'user', 'Warnings') @@ -97,7 +89,6 @@ class User(ModelSQL, ModelView): cls._context_fields = [ 'language', 'language_direction', - 'timezone', 'groups', ] cls._error_messages.update({ diff --git a/trytond/res/view/user_form.xml b/trytond/res/view/user_form.xml index 3cdcab7598..a296cdfff8 100644 --- a/trytond/res/view/user_form.xml +++ b/trytond/res/view/user_form.xml @@ -29,8 +29,6 @@ this repository contains the full copyright notices and license terms. --> diff --git a/trytond/res/view/user_form_preferences.xml b/trytond/res/view/user_form_preferences.xml index 8e342866aa..84fbd22554 100644 --- a/trytond/res/view/user_form_preferences.xml +++ b/trytond/res/view/user_form_preferences.xml @@ -24,8 +24,6 @@ this repository contains the full copyright notices and license terms. --> diff --git a/trytond/server.py b/trytond/server.py index 23a1989664..720b224b61 100644 --- a/trytond/server.py +++ b/trytond/server.py @@ -29,7 +29,6 @@ class TrytonServer(object): CONFIG.update_etc(options['configfile']) CONFIG.update_cmdline(options) - CONFIG.set_timezone() if CONFIG['logfile']: logf = CONFIG['logfile'] diff --git a/trytond/tests/test_tryton.py b/trytond/tests/test_tryton.py index fb35ab2b8f..e5ffc9bc4b 100644 --- a/trytond/tests/test_tryton.py +++ b/trytond/tests/test_tryton.py @@ -38,7 +38,6 @@ if __name__ == '__main__': from trytond.config import CONFIG CONFIG['db_type'] = 'sqlite' CONFIG.update_etc(_CONFIGFILE) -CONFIG.set_timezone() if not CONFIG['admin_passwd']: CONFIG['admin_passwd'] = 'admin'