Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
robinkeunen committed Mar 15, 2022
1 parent 6d2e9e7 commit f78d3a1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions beesdoo_shift/models/cooperative_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,15 @@ def _compute_next_shift(self):
todays = self.mapped("today")
if len(todays) == 1:
today = todays.pop()
# today rather than now (naming)
now = datetime(today.year, today.month, today.day, 0, 0, 0)
else:
now = datetime.now()
now = datetime.now() # never reaches here

# avoid searching for shift in loop
cooperator_ids = self.mapped("cooperator_id").ids
# rather take earliest "confirmed" in order to take into account
# partners for which the counter was not incremented
next_shifts = self.env["beesdoo.shift.shift"].search(
[("start_time", ">=", now), ("worker_id", "in", cooperator_ids)],
order="worker_id, start_time",
Expand All @@ -454,7 +457,7 @@ def _compute_next_shift(self):
for shift in next_shifts:
# take fist shift for each worker
next_shift_by_worker.setdefault(shift.worker_id.id, shift)

# what happens when no future shift ?
for rec in self:
rec.next_shift_id = next_shift_by_worker.get(rec.cooperator_id.id)
if rec.next_shift_id:
Expand Down

0 comments on commit f78d3a1

Please sign in to comment.