From f78d3a15fe2addb62196411df06d7912f740a841 Mon Sep 17 00:00:00 2001 From: "robin.keunen" Date: Mon, 14 Mar 2022 14:53:17 +0100 Subject: [PATCH] wip --- beesdoo_shift/models/cooperative_status.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/beesdoo_shift/models/cooperative_status.py b/beesdoo_shift/models/cooperative_status.py index 924eb8687..c34c6bfc3 100644 --- a/beesdoo_shift/models/cooperative_status.py +++ b/beesdoo_shift/models/cooperative_status.py @@ -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", @@ -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: