Browse Source

[FIX] b_shift : next_countdown computation

When the next_countdown is the same day than the current one,
it should be the one displayed (and not the one 28 days later).
pull/120/head
Elouan Le Bars 5 years ago
committed by Rémy Taymans
parent
commit
c726b28574
  1. 11
      beesdoo_shift/models/cooperative_status.py

11
beesdoo_shift/models/cooperative_status.py

@ -137,7 +137,7 @@ class CooperativeStatus(models.Model):
date = rec.today date = rec.today
counter = rec.sr counter = rec.sr
# Simulate the countdown # Simulate the countdown
while counter >= 0:
while counter > 0:
date = add_days_delta(date, 1) date = add_days_delta(date, 1)
date = self._next_countdown_date(rec.irregular_start_date, date = self._next_countdown_date(rec.irregular_start_date,
date) date)
@ -154,7 +154,9 @@ class CooperativeStatus(models.Model):
continue continue
else: else:
counter -= 1 counter -= 1
rec.future_alert_date = date
rec.future_alert_date = self._next_countdown_date(
rec.irregular_start_date, date
)
@api.depends('today', 'irregular_start_date', 'holiday_start_time', @api.depends('today', 'irregular_start_date', 'holiday_start_time',
'holiday_end_time', 'temporary_exempt_start_date', 'holiday_end_time', 'temporary_exempt_start_date',
@ -181,18 +183,19 @@ class CooperativeStatus(models.Model):
date = rec.today date = rec.today
next_countdown_date = False next_countdown_date = False
while not next_countdown_date: while not next_countdown_date:
date = add_days_delta(date, 1)
date = self._next_countdown_date(rec.irregular_start_date, date) date = self._next_countdown_date(rec.irregular_start_date, date)
# Check holidays # Check holidays
if (rec.holiday_start_time and rec.holiday_end_time if (rec.holiday_start_time and rec.holiday_end_time
and date >= rec.holiday_start_time and date >= rec.holiday_start_time
and date <= rec.holiday_end_time): and date <= rec.holiday_end_time):
date = add_days_delta(date, 1)
continue continue
# Check temporary exemption # Check temporary exemption
elif (rec.temporary_exempt_start_date elif (rec.temporary_exempt_start_date
and rec.temporary_exempt_end_date and rec.temporary_exempt_end_date
and date >= rec.temporary_exempt_start_date and date >= rec.temporary_exempt_start_date
and date <= rec.temporary_exempt_end_date): and date <= rec.temporary_exempt_end_date):
date = add_days_delta(date, 1)
continue continue
else: else:
next_countdown_date = date next_countdown_date = date
@ -208,6 +211,8 @@ class CooperativeStatus(models.Model):
today_dt = fields.Date.from_string(today) today_dt = fields.Date.from_string(today)
irregular_start_dt = fields.Date.from_string(irregular_start_date) irregular_start_dt = fields.Date.from_string(irregular_start_date)
delta = (today_dt - irregular_start_dt).days delta = (today_dt - irregular_start_dt).days
if not delta % PERIOD:
return today
return add_days_delta(today, PERIOD - (delta % PERIOD)) return add_days_delta(today, PERIOD - (delta % PERIOD))
def _set_regular_status(self, grace_delay, alert_delay): def _set_regular_status(self, grace_delay, alert_delay):

Loading…
Cancel
Save