Files
odoo_source/addons/hr_holidays
Youssef Bashandy 9dac77e414 [FIX] hr_holidays : saving 'default_date_from' with another key
Steps to reproduce:
	1- Create an allocation with validity date (e.g. 01-01-2024 -> 30-06-2024)
	 and another one starts after the first one (e.g. 01-07-2024 -> 31-12-2024)
	2- Go to Time off module and select a date in the second allocation's period
	3- Click on the Time off type dropdown menu
	4- You will see the first allocation displayed not the second one

Current behavior before PR:
The display name of some leaves gets computed in a wrong way.
This is happening because after fetching the right allocation
we compute the display name but this time we don't have
the 'default_date_from' in context so since
it became one of the fields that triggers '_compute_leaves'
https://github.com/odoo/odoo/blob/17.0/addons/hr_holidays/models/hr_leave_type.py#L218:L219
we compute the leaves once again but the target_date will be none
and it will get assigned with today's date in 'get_allocation_data'
https://github.com/odoo/odoo/blob/17.0/addons/hr_holidays/models/hr_leave_type.py#L380:L381

Desired behavior after PR is merged:
This has been solved by saving the date attribute in the context
with another name as when computing the display_name we call sudo so clean_context()
removes the 'default_' context keys. Now when it gets removed we are
going to have the same value but with another name.

opw-3797696

closes odoo/odoo#159917

Signed-off-by: Youssef Bashandy (yoba) <yoba@odoo.com>
2024-04-18 15:05:18 +00:00
..