Skip to content

Commit 35ef4b2

Browse files
committed
[FIX] hr_holidays: accrual plans access rights
Accrual plans are not readable for regular users, so once a user has an accrual plan set on one of his allocation, he cannot open anymore his time off dashboard when it tries to get his allocation data (the time off he has). To ensure the correct computation of available time off, we add a sudo. This has been introduced in odoo#172892 closes odoo#187888 X-original-commit: 30f7fe6 Signed-off-by: Bertrand Dossogne (bedo) <[email protected]> Signed-off-by: Pierre Masereel (pim) <[email protected]>
1 parent 91cffe9 commit 35ef4b2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

addons/hr_holidays/models/hr_leave_type.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ def _get_closest_expiring_leaves_date_and_count(self, allocations, remaining_lea
599599
for allocation in allocations:
600600
expiration_date = allocation.date_to
601601

602-
accrual_plan_level = allocation._get_current_accrual_plan_level_id(target_date)[0]
602+
accrual_plan_level = allocation.sudo()._get_current_accrual_plan_level_id(target_date)[0]
603603
carryover_policy = accrual_plan_level.action_with_unused_accruals if accrual_plan_level else False
604604
carryover_date = False
605605
if carryover_policy in ['maximum', 'lost']:
@@ -626,7 +626,7 @@ def _get_closest_expiring_leaves_date_and_count(self, allocations, remaining_lea
626626
if expiration_date and expiration_date == closest_expiration_date:
627627
expiring_leaves_count += remaining_leaves[allocation]['virtual_remaining_leaves']
628628
elif carryover_date and carryover_date == closest_expiration_date:
629-
accrual_plan_level = allocation._get_current_accrual_plan_level_id(target_date)[0]
629+
accrual_plan_level = allocation.sudo()._get_current_accrual_plan_level_id(target_date)[0]
630630
expiring_leaves_count += max(0, remaining_leaves[allocation]['virtual_remaining_leaves'] - accrual_plan_level.postpone_max_days)
631631
if expiring_leaves_count != 0:
632632
return closest_expiration_date, expiring_leaves_count

0 commit comments

Comments
 (0)