Skip to content
Snippets Groups Projects
Commit 2ddabf08 authored by Touati Djamel (otd)'s avatar Touati Djamel (otd)
Browse files

[FIX] hr_holidays: Prevent allocation date_to from switching to another day


Steps to reproduce the bug:

Go to your computer's date settings
Change region, e.g: (US or choose a region with a negative UTC)
Go to the preferences settings in odoo > Change the timezone to US too
Go to Time Off app > Manager > Allocations > Create a new one
Allocation type : "Accrual Allocation"
Set the end date to, e.g: "04/07/2021"
save

Problem:
The end date moves back by one day.
The field " date_to " is of ”datetime” type, so we use in the view "widget="date"
Therefore, the user can only choose the date. We save the time in the database at" 00: 00:00 ".
But as we use in the view "widget="date", after saving the record,
the datetime will be converted to a date, based on the user's UTC.

For example, in our case:
in database, date_to = "2021-07-04 00:00:00"
user UTC = "UTC-6"
result = "2021-07-04 00:00:00" - 06:00:00 → "2021-07-03 00:18:00"

Solution:
Remove the widget date to allow a user entering the full date (eg: 2021-07-04 23:00:00), that
will be stored correctly in UTC afterwards, instead of having the widget making the date switch to
another day.

opw-2607082

closes odoo/odoo#75193

X-original-commit: ceef1983
Signed-off-by: default avatarYannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: default avatarDjamel Touati <DjamelTouati@users.noreply.github.com>
parent 22b5d905
Branches
Tags
No related merge requests found
......@@ -163,8 +163,8 @@
<xpath expr="//field[@name='allocation_type']" position="after">
<label for="date_from" attrs="{'invisible': [('allocation_type', '=', 'regular')]}"/>
<div class="o_row" attrs="{'invisible': [('allocation_type', '=', 'regular')]}">
<field name="date_from" widget="date" class="mr-2" attrs="{'required': [('allocation_type', '=', 'accrual')]}" />
Run until <field name="date_to" help="If no value set, runs indefinitely" class="ml-2" widget="date"/>
<field name="date_from" class="mr-2" attrs="{'required': [('allocation_type', '=', 'accrual')]}" />
Run until <field name="date_to" help="If no value set, runs indefinitely" class="ml-2"/>
</div>
<label for="date_from" invisible="1"/>
<div attrs="{'invisible': [('allocation_type', '=', 'regular')]}">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment