Files
odoo_source/addons/hr_holidays/static
Levi Siuzdak (sile) fcfadf1663 [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 0a0c6917b5 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

closes odoo/odoo#162203

X-original-commit: 134455167734d101a8ce923043700e5fc8f497bd
Signed-off-by: Levi Siuzdak <sile@odoo.com>
2024-04-18 00:32:41 +00:00
..