Reputation: 69100
I understand that OpenERP since 6.1 decided to exclusively use the UTC timezone for storage of datetimes, but why does it ignore the timezone of my tz-aware datetimes?
Upvotes: 0
Views: 371
Reputation: 69100
This is a bug in OpenERP probably since 6.1. This patch (against 7.0) fixes it.
For the curious, the heart of the fix is a few lines to the .../openerp/osv/fields.py
module:
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
Upvotes: 1