[FIX] mail: track date change

- Set your timezone in Brasil
- Install the Maintenance module
- Create a Maintenance Request, set the Requested Date to 2017-06-15
- Save

In the chatter, the track fields message shows a Requested Date of
2017-06-14.

This can actually happen with any date tracked. The issue comes from the
web client: it converts the date in UTC, which should of course not be
done. This only applies for a datetime, not for a date.

opw-746216
This commit is contained in:
Nicolas Martinelli
2017-06-21 20:57:16 +02:00
parent 2662739187
commit a03fc2d849
+10 -2
View File
@@ -287,14 +287,22 @@ function make_message (data) {
// can not be done in preprocess, since it alter the original value
if (msg.tracking_value_ids && msg.tracking_value_ids.length) {
_.each(msg.tracking_value_ids, function(f) {
if (_.contains(['date', 'datetime'], f.field_type)) {
var format = (f.field_type === 'date') ? 'LL' : 'LLL';
if (f.field_type === 'datetime') {
var format = 'LLL';
if (f.old_value) {
f.old_value = moment.utc(f.old_value).local().format(format);
}
if (f.new_value) {
f.new_value = moment.utc(f.new_value).local().format(format);
}
} else if (f.field_type === 'date') {
var format = 'LL';
if (f.old_value) {
f.old_value = moment(f.old_value).local().format(format);
}
if (f.new_value) {
f.new_value = moment(f.new_value).local().format(format);
}
}
});
}