From bcc24a226fc57fe277c07cd4fef996ff943bbe7e Mon Sep 17 00:00:00 2001 From: Elouan Le Bars Date: Fri, 6 Dec 2019 12:22:51 +0100 Subject: [PATCH] [FIX] b_shift : search on equal dates --- beesdoo_shift/models/attendance_sheet.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/beesdoo_shift/models/attendance_sheet.py b/beesdoo_shift/models/attendance_sheet.py index a3d79a2..353f1af 100644 --- a/beesdoo_shift/models/attendance_sheet.py +++ b/beesdoo_shift/models/attendance_sheet.py @@ -377,10 +377,17 @@ class AttendanceSheet(models.Model): # Creation and addition of the expected shifts corresponding # to the time range tasks = self.env["beesdoo.shift.shift"] + + s_time = fields.Datetime.from_string(new_sheet.start_time) + e_time = fields.Datetime.from_string(new_sheet.end_time) + delta = timedelta(minutes=1) + tasks = tasks.search( [ - ("start_time", "=", new_sheet.start_time), - ("end_time", "=", new_sheet.end_time), + ("start_time", ">", fields.Datetime.to_string(s_time - delta)), + ("start_time", "<", fields.Datetime.to_string(s_time + delta)), + ("end_time", ">", fields.Datetime.to_string(e_time - delta)), + ("end_time", "<", fields.Datetime.to_string(e_time + delta)), ] ) expected_shift = self.env["beesdoo.shift.sheet.expected"] @@ -566,7 +573,7 @@ class AttendanceSheet(models.Model): @api.model def _generate_attendance_sheet(self): """ - Generate sheets 20 minutes before current time. + Generate sheets 20 minutes before their start time. Corresponding CRON intervall time must be the same. Check if any task exists in the time intervall. """