我知道自6.1以来OpenERP决定专门使用UTC时区存储日期时间,但为什么它会忽略我的tz感知日期时间的时区?
答案 0 :(得分:1)
自6.1以来,这是一个bug in OpenERP。 This patch(针对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