From eb673297c3dfb39a36b3b15abdd1f28ffc04b49c Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 19 Jun 2017 10:08:36 +0200 Subject: [PATCH] [FIX] mail: add TZ to datetime tracking Add the TZ to the datetime tracking. At the moment, the TZ is fixed: it is UTC. However, this avoids any ambiguity when the tracking message is sent by mail, since in this case, the datetime is not converted automatically to the TZ of the user. Adding a simple 'Z' makes the datetime compliant with ISO 8601, so it is supported by the web client as well. opw-747367 --- addons/mail/models/mail_tracking_value.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/mail/models/mail_tracking_value.py b/addons/mail/models/mail_tracking_value.py index da38a678d06..5fbe63d6a14 100644 --- a/addons/mail/models/mail_tracking_value.py +++ b/addons/mail/models/mail_tracking_value.py @@ -75,8 +75,14 @@ class MailTracking(models.Model): assert type in ('new', 'old') result = [] for record in self: - if record.field_type in ['integer', 'float', 'char', 'text', 'datetime', 'monetary']: + if record.field_type in ['integer', 'float', 'char', 'text', 'monetary']: result.append(getattr(record, '%s_value_%s' % (type, record.field_type))) + elif record.field_type == 'datetime': + if record['%s_value_datetime' % type]: + new_datetime = getattr(record, '%s_value_datetime' % type) + result.append('%sZ' % new_datetime) + else: + result.append(record['%s_value_datetime' % type]) elif record.field_type == 'date': if record['%s_value_datetime' % type]: new_date = datetime.strptime(record['%s_value_datetime' % type], tools.DEFAULT_SERVER_DATETIME_FORMAT).date()