Skip to content

Commit

Permalink
[FIX] shift_worker_status: compute dates
Browse files Browse the repository at this point in the history
next_countdown_date and future_alert_date were not computed the same
way, leading to differences for an irregular worker, with a counter (sr)
equal to zero and an exemption set during the next countdown date.
  • Loading branch information
remytms committed Dec 16, 2024
1 parent a41ad91 commit 21ef06f
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions shift_worker_status/models/cooperative_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def _compute_future_alert_date(self):
date = rec.today
counter = rec.sr
# Simulate the countdown
while counter > 0:
future_alert_date = False
while not future_alert_date or counter > 0:
date = self._next_countdown_date(rec.irregular_start_date, date)
# Check holidays
if (
Expand All @@ -59,22 +60,21 @@ def _compute_future_alert_date(self):
and date <= rec.holiday_end_time
):
date = add_days_delta(date, 1)
continue
# Check temporary exemption
if (
elif (
rec.temporary_exempt_start_date
and rec.temporary_exempt_end_date
and date >= rec.temporary_exempt_start_date
and date <= rec.temporary_exempt_end_date
):
date = add_days_delta(date, 1)
continue
# Otherwise
date = add_days_delta(date, 1)
counter -= 1
rec.future_alert_date = self._next_countdown_date(
rec.irregular_start_date, date
)
# If counter is not zero then decrement it
elif counter > 0:
date = add_days_delta(date, 1)
counter -= 1
else:
future_alert_date = date
rec.future_alert_date = future_alert_date

@api.depends(
"today",
Expand Down Expand Up @@ -116,18 +116,17 @@ def _compute_next_countdown_date(self):
and date <= rec.holiday_end_time
):
date = add_days_delta(date, 1)
continue
# Check temporary exemption
if (
elif (
rec.temporary_exempt_start_date
and rec.temporary_exempt_end_date
and date >= rec.temporary_exempt_start_date
and date <= rec.temporary_exempt_end_date
):
date = add_days_delta(date, 1)
continue
# Otherwise
next_countdown_date = date
else:
next_countdown_date = date
rec.next_countdown_date = next_countdown_date

#####################################
Expand Down

0 comments on commit 21ef06f

Please sign in to comment.