[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
This commit is contained in:
Nicolas Martinelli
2017-06-19 10:11:56 +02:00
parent 18e8f4bdee
commit eb673297c3
+7 -1
View File
@@ -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()