我知道OpenERP从6.1开始就决定只使用UTC时区来存储日期时间,但为什么它忽略了我的tz感知日期时间的时区?
这是OpenERP中的一个错误,可能是从6.1开始的。这个补丁(针对7.0)修复了它。
对于好奇的人来说,修复的核心是.../openerp/osv/fields.py
模块的几行:
UTC = pytz.timezone('UTC')
.
.
.
class datetime(_column):
...
_symbol_c = '%s'
def _symbol_f(symb):
if symb is None or symb == False:
return None
elif isinstance(symb, unicode):
symb = symb.encode('utf-8')
if not isinstance(symb, str):
# had better be something that quacks like a datetime
if symb.tzinfo is not None:
symb = symb.astimezone(UTC)
symb = symb.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)
return symb
_symbol_set = (_symbol_c, _symbol_f)
...
class function(_column):
...
if type == 'datetime':
self._symbol_c = datetime._symbol_c
self._symbol_f = datetime._symbol_f
self._symbol_set = datetime._symbol_set