From c9de5d9457f0889aa881b8f26bc633101a995c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Taymans?= Date: Thu, 30 Apr 2020 20:01:54 +0200 Subject: [PATCH] [FIX] b_shift_attendance --- .../models/attendance_sheet.py | 6 ++-- beesdoo_shift_attendance/security/group.xml | 1 + .../tests/test_beesdoo_shift.py | 29 +++++++++---------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/beesdoo_shift_attendance/models/attendance_sheet.py b/beesdoo_shift_attendance/models/attendance_sheet.py index b668bbb..df8669e 100644 --- a/beesdoo_shift_attendance/models/attendance_sheet.py +++ b/beesdoo_shift_attendance/models/attendance_sheet.py @@ -527,7 +527,6 @@ class AttendanceSheet(models.Model): def validate_with_checks(self): self.ensure_one() - if self.state == "validated": raise UserError(_("The sheet has already been validated.")) if self.start_time > datetime.now(): @@ -606,7 +605,6 @@ class AttendanceSheet(models.Model): Generate sheets with shifts in the time interval defined from corresponding CRON time interval. """ - tasks = self.env["beesdoo.shift.shift"] sheets = self.env["beesdoo.shift.sheet"] current_time = datetime.now() @@ -620,8 +618,8 @@ class AttendanceSheet(models.Model): tasks = tasks.search( [ - ("start_time", ">", str(current_time),), - ("start_time", "<", str(current_time + allowed_time_range),), + ("start_time", ">", str(current_time)), + ("start_time", "<", str(current_time + allowed_time_range)), ] ) diff --git a/beesdoo_shift_attendance/security/group.xml b/beesdoo_shift_attendance/security/group.xml index 4ad07fb..bc19ba3 100644 --- a/beesdoo_shift_attendance/security/group.xml +++ b/beesdoo_shift_attendance/security/group.xml @@ -7,6 +7,7 @@ Attendance Sheet Validation + diff --git a/beesdoo_shift_attendance/tests/test_beesdoo_shift.py b/beesdoo_shift_attendance/tests/test_beesdoo_shift.py index 5ccca63..0e4943a 100644 --- a/beesdoo_shift_attendance/tests/test_beesdoo_shift.py +++ b/beesdoo_shift_attendance/tests/test_beesdoo_shift.py @@ -57,23 +57,22 @@ class TestBeesdooShift(TransactionCase): ) self.task_type_1 = self.env.ref( - "beesdoo_shift_attendance" - ".beesdoo_shift_attendance_task_type_1_demo" + "beesdoo_shift.beesdoo_shift_task_type_1_demo" ) self.task_type_2 = self.env.ref( - "beesdoo_shift_attendance" - ".beesdoo_shift_attendance_task_type_2_demo" + "beesdoo_shift.beesdoo_shift_task_type_2_demo" ) self.task_type_3 = self.env.ref( - "beesdoo_shift_attendance" - ".beesdoo_shift_attendance_task_type_3_demo" + "beesdoo_shift.beesdoo_shift_task_type_3_demo" ) self.task_template_1 = self.env.ref( - "beesdoo_shift.beesdoo_shift_task_template_1_demo" + "beesdoo_shift_attendance" + ".beesdoo_shift_attendance_task_template_1_demo" ) self.task_template_2 = self.env.ref( - "beesdoo_shift.beesdoo_shift_task_template_2_demo" + "beesdoo_shift_attendance" + ".beesdoo_shift_attendance_task_template_2_demo" ) # Set time in and out of generation interval parameter @@ -292,16 +291,16 @@ class TestBeesdooShift(TransactionCase): self.assertFalse(shift.is_compensation) # Add a worker that should be replaced - with self.assertRaises(UserError) as e: + with self.assertRaises(UserError): sheet_1.on_barcode_scanned(421457731742) # Wrong barcode - with self.assertRaises(UserError) as e: + with self.assertRaises(UserError): sheet_1.on_barcode_scanned(101010) # Add an unsubscribed worker self.worker_regular_1.cooperative_status_ids.sr = -2 self.worker_regular_1.cooperative_status_ids.sc = -2 - with self.assertRaises(UserError) as e: + with self.assertRaises(UserError): sheet_1.on_barcode_scanned(421457731745) def test_attendance_sheet_edition(self): @@ -351,9 +350,9 @@ class TestBeesdooShift(TransactionCase): # Wait necessary time for shifts to begin waiting_time = (self.start_in_1 - datetime.now()).total_seconds() if waiting_time > 0: - with self.assertRaises(UserError) as e: + with self.assertRaises(UserError) as econtext: sheet_1.validate_with_checks() - self.assertIn("wait", str(e.exception)) + self.assertIn("once the shifts have started", str(econtext.exception)) time.sleep(waiting_time) sheet_1.worker_nb_feedback = "enough" @@ -362,9 +361,9 @@ class TestBeesdooShift(TransactionCase): sheet_1.validate_with_checks() - with self.assertRaises(UserError) as e: + with self.assertRaises(UserError) as econtext: sheet_1.validate_with_checks() - self.assertIn("already been validated", str(e.exception)) + self.assertIn("already been validated", str(econtext.exception)) self.assertEqual(sheet_1.state, "validated") self.assertEqual(sheet_1.validated_by, self.user_admin.partner_id)