Skip to content

Commit

Permalink
[IMP] hr_contract_employee_calendar_planning: sort contracts and cale…
Browse files Browse the repository at this point in the history
…ndars chronologically
  • Loading branch information
jonasbuchholz committed Dec 14, 2023
1 parent f8320e0 commit e5567d4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions hr_contract_employee_calendar_planning/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def post_init_hook(cr, registry, employees=None):

for employee in employees.filtered("contract_ids"):
contract_calendar_lines = []
for contract in employee.contract_ids:
for contract in employee.contract_ids.sorted("date_start"):
date_start = contract.date_start
date_end = contract.date_end
# filter calendar_ids to check for overlaps with contracts
Expand All @@ -26,7 +26,7 @@ def post_init_hook(cr, registry, employees=None):
)
if cal_ids:
_logger.info(f"{contract} is overlapping with {cal_ids}")
for calendar in cal_ids:
for calendar in cal_ids.sorted("date_start"):
if date_start and calendar.date_start != date_start:
_logger.info(
f"changing date_start of {calendar} "
Expand All @@ -39,6 +39,7 @@ def post_init_hook(cr, registry, employees=None):
f"from {calendar.date_end} to {date_end}"
)
calendar.date_end = date_end
break
else:
_logger.info(
f"adding new calendar_id for {contract.employee_id.name}: "
Expand Down

0 comments on commit e5567d4

Please sign in to comment.