[FIX] mail: preprocess tracking fields of type date/datetime only once
Before this commit, if a message thread was loaded 2 times, the first time the date was well formatted, the second time that fail because momentjs cannot parse the localized date from some locale. Luckily, it was not bugged by default in english, because moment was able to reparse a localized US date. But in some local as french, momentjs cannot parse the localized date and return 'Invalid date' Now, we move the code, to be processed only once by the chat manager, and not in each process of the thread. This commit closes issue #13258 Courtesy of @aab-odoo
This commit is contained in:
@@ -282,6 +282,22 @@ function make_message (data) {
|
||||
a.url = '/web/content/' + a.id + '?download=true';
|
||||
});
|
||||
|
||||
// format date to the local only once by message
|
||||
// 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.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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@@ -151,20 +151,6 @@ var Thread = Widget.extend({
|
||||
msg.hour = msg.date.format('LT');
|
||||
}
|
||||
|
||||
if (message.tracking_value_ids && message.tracking_value_ids.length) {
|
||||
_.each(message.tracking_value_ids, function(f) {
|
||||
if (_.contains(['date', 'datetime'], f.field_type)) {
|
||||
var format = (f.field_type === 'date') ? 'LL' : '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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (_.contains(this.expanded_msg_ids, message.id)) {
|
||||
msg.expanded = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user