From 6cf8ff8ed756d2d19037c59bfa4fb202feae4db3 Mon Sep 17 00:00:00 2001 From: "Audric Onockx (auon)" Date: Tue, 17 Aug 2021 07:55:28 +0000 Subject: [PATCH] [FIX] hr_holidays: Fix accrual dates based on creation date Steps: 1. Create new time off allocation 2. Set type to accrual and set start date other than present day 3. Set the accrual to add every month 4. Validate and run the scheduled action for Accrual Time Off 5. Check the field 'nextcall' with Studio or editing form view Result: Nextcall date is set to 1 month after the date of creation of allocation record instead of start date. Solution: Nextcall is now based on start date. opw-2558480 closes odoo/odoo#75234 X-original-commit: 3f7f0feb31d80c5cb3364c3a7d530c80b6278b40 Signed-off-by: Anh Thao PHAM Signed-off-by: Audric Onockx --- addons/hr_holidays/models/hr_leave_allocation.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/hr_holidays/models/hr_leave_allocation.py b/addons/hr_holidays/models/hr_leave_allocation.py index 995272f80c6..eda52005cbf 100644 --- a/addons/hr_holidays/models/hr_leave_allocation.py +++ b/addons/hr_holidays/models/hr_leave_allocation.py @@ -183,7 +183,12 @@ class HolidaysAllocation(models.Model): if holiday.interval_unit == 'years': delta = relativedelta(years=holiday.interval_number) - values['nextcall'] = (holiday.nextcall if holiday.nextcall else today) + delta + if holiday.nextcall: + values['nextcall'] = holiday.nextcall + delta + else: + values['nextcall'] = holiday.date_from + while values['nextcall'] <= datetime.combine(today, time(0, 0, 0)): + values['nextcall'] += delta period_start = datetime.combine(today, time(0, 0, 0)) - delta period_end = datetime.combine(today, time(0, 0, 0))