You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[FIX] hr_holidays: don't assume default date strings are datetimes
Versions
--------
- saas-16.3+
Steps
-----
1. Set timezone of User and browser to America/Los_Angeles;
2. go to Time Off;
3. click on calendar to create a new leave.
Issue
-----
Date defaults to the day before the selected date.
Cause
-----
Commit 0a0c691 added a TZ conversion in
JS to add default start & end times for leaves. The issue is that it
assumes the context values are always datetime strings, therefore always
using `deserializeDateTime`, which does a timezone conversion from UTC
to local time, which is incorrect when the context values are date
strings.
For a UTC-7 zone like America/Los_Angeles, it deserializes a date string
like '2024-01-01' to '2023-12-12 17:00:00' (7 hours before midnight). It
then sets the start hour to 7, and serializes it back to UTC, adding 7
hours, resulting in '2023-12-12 14:00:00'. Instead, Jan 1, 7 AM in
America/Los_Angeles should convert to '2024-01-01 14:00:00' UTC.
Solution
--------
Use `deserializeDate` instead of `deserializeDateTime` when the
`default_date_{from,to}` in the context is a date rather than a
datetime. This way, '2024-01-01' gets deserialized into '2024-01-01
00:00:00' local time. When this value gets used for the default hours,
'2024-01-01 07:00:00' local time will get serialized to '2024-01-01
14:00:00' UTC as expected.
opw-3757712
closesodoo#162270
X-original-commit: 1344551
Signed-off-by: Levi Siuzdak <[email protected]>
0 commit comments