[FIX] mail: don't apply system timezone on tracked date value in chatter
Steps to reproduce:
- Add a date field in a model with `tracking=True`
- Log with a user with timezone set to UTC+2
- Create a record and set the date field to any date.
- Update the date value to another date
(Should have logged a message in the chatter with changes)
- Log with a user with timezone set to `America/Los Angeles`
- Check the chatter of the record created above
Issue:
New date value displayed in the chatter is wrong (set to one day
before).
Cause:
The value displayed in the chatter is the date value converted first
as datetime (with Luxon library), then the system timezone is set on
it and therefore might change the day.
Solution:
Use `deserializeDate` instead, who has the same computation as
`deserializeDatetime` (with the sole difference of date vs datetime)
and therefore will not apply a timezone on the date.
opw-3427502
closes odoo/odoo#142034
X-original-commit: ca3254f8c7700fe78053072710f0c57fee60af5b
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Nasreddin Boulif (bon) <bon@odoo.com>
This commit is contained in:
@@ -3,7 +3,12 @@
|
||||
import { Message } from "@mail/core/common/message";
|
||||
import { markEventHandled } from "@web/core/utils/misc";
|
||||
|
||||
import { deserializeDateTime, formatDate, formatDateTime } from "@web/core/l10n/dates";
|
||||
import {
|
||||
deserializeDate,
|
||||
deserializeDateTime,
|
||||
formatDate,
|
||||
formatDateTime,
|
||||
} from "@web/core/l10n/dates";
|
||||
import { _t } from "@web/core/l10n/translation";
|
||||
import {
|
||||
formatChar,
|
||||
@@ -69,13 +74,12 @@ patch(Message.prototype, {
|
||||
case "many2one":
|
||||
case "selection":
|
||||
return formatChar(trackingValue.value);
|
||||
case "date":
|
||||
if (trackingValue.value) {
|
||||
return luxon.DateTime.fromISO(trackingValue.value, { zone: "utc" })
|
||||
.setZone("system")
|
||||
.toLocaleString({ locale: this.userService.lang.replace("_", "-") });
|
||||
}
|
||||
return formatDate(trackingValue.value);
|
||||
case "date": {
|
||||
const value = trackingValue.value
|
||||
? deserializeDate(trackingValue.value)
|
||||
: trackingValue.value;
|
||||
return formatDate(value);
|
||||
}
|
||||
case "datetime": {
|
||||
const value = trackingValue.value
|
||||
? deserializeDateTime(trackingValue.value)
|
||||
|
||||
Reference in New Issue
Block a user