diff --git a/beesdoo_shift/models/attendance_sheet.py b/beesdoo_shift/models/attendance_sheet.py index 6eb17ec..2c1e800 100644 --- a/beesdoo_shift/models/attendance_sheet.py +++ b/beesdoo_shift/models/attendance_sheet.py @@ -314,6 +314,12 @@ class AttendanceSheet(models.Model): ) def on_barcode_scanned(self, barcode): + if self.env.user.has_group("beesdoo_shift.group_shift_attendance"): + raise UserError( + _("You must be logged as 'Attendance Sheet Generic Access' " + " if you want to scan cards.") + ) + if self.state == "validated": raise UserError( _("A validated attendance sheet can't be modified") @@ -578,7 +584,7 @@ class AttendanceSheet(models.Model): ) # Open a validation wizard only if not admin - if self.env.user.has_group("beesdoo_shift.group_cooperative_admin"): + if self.env.user.has_group("beesdoo_shift.group_shift_attendance_sheet_validation"): if not self.worker_nb_feedback: raise UserError( _("Please give your feedback about the number of workers.") diff --git a/beesdoo_shift/security/group.xml b/beesdoo_shift/security/group.xml index 6e1b37f..fb2e671 100644 --- a/beesdoo_shift/security/group.xml +++ b/beesdoo_shift/security/group.xml @@ -4,12 +4,18 @@ Attendance Sheet Generic Access + + Attendance Sheet Validation + + + - Shift and Worker Access + Shift and Worker Read Access + - Shift Management + Shifts and Attendance Sheets Management @@ -22,7 +28,8 @@ Cooperative Admin diff --git a/beesdoo_shift/security/ir.model.access.csv b/beesdoo_shift/security/ir.model.access.csv index 54c57d2..76458a3 100644 --- a/beesdoo_shift/security/ir.model.access.csv +++ b/beesdoo_shift/security/ir.model.access.csv @@ -12,13 +12,13 @@ access_beesdoo_shift_daynumber,access_beesdoo_shift_daynumber,model_beesdoo_shif read_beesdoo_shift_planning,read_beesdoo_shift_planning,model_beesdoo_shift_planning,,1,0,0,0 access_beesdoo_shift_template,access_beesdoo_shift_template,model_beesdoo_shift_template,group_shift_attendance,1,0,0,0 write_beesdoo_shift_shift,write_beesdoo_shift_shift,model_beesdoo_shift_shift,group_shift_attendance,1,1,0,0 -manage_beesdoo_shift_shift,manage_beesdoo_shift_shift,model_beesdoo_shift_shift,group_shift_management,1,1,1,1 +manage_beesdoo_shift_shift,manage_beesdoo_shift_shift,model_beesdoo_shift_shift,group_shift_attendance,1,1,1,1 manage_beesdoo_shift_type,manage_beesdoo_shift_type,model_beesdoo_shift_type,group_planning_management,1,1,1,1 manage_beesdoo_shift_daynumber,manage_beesdoo_shift_daynumber,model_beesdoo_shift_daynumber,group_planning_management,1,1,1,1 manage_beesdoo_shift_planning,manage_beesdoo_shift_planning,model_beesdoo_shift_planning,group_planning_management,1,1,1,1 manage_beesdoo_shift_template,manage_beesdoo_shift_template,model_beesdoo_shift_template,group_planning_management,1,1,1,1 -manage_beesdoo_shift_sheet_shift,beesdoo_shift_sheet_shift,model_beesdoo_shift_sheet_shift,group_cooperative_admin,1,1,1,1 -manage_beesdoo_shift_sheet_expected,manage_beesdoo_shift_sheet_expected,model_beesdoo_shift_sheet_expected,group_cooperative_admin,1,1,1,1 +manage_beesdoo_shift_sheet_shift,beesdoo_shift_sheet_shift,model_beesdoo_shift_sheet_shift,group_shift_attendance,1,1,1,1 +manage_beesdoo_shift_sheet_expected,manage_beesdoo_shift_sheet_expected,model_beesdoo_shift_sheet_expected,group_shift_attendance,1,1,1,1 manage_cooperative_status,manage_cooperative_status,model_cooperative_status,group_cooperative_admin,1,1,1,1 manage_cooperative_exempt_reason,manage_cooperative_exempt_reason,model_cooperative_exempt_reason,group_cooperative_admin,1,1,1,1 read_beesdoo_shift_journal,read_beesdoo_shift_journal,model_beesdoo_shift_journal,group_cooperative_admin,1,0,1,1 diff --git a/beesdoo_shift/tests/test_beesdoo_shift.py b/beesdoo_shift/tests/test_beesdoo_shift.py index 78d827a..4ed1588 100644 --- a/beesdoo_shift/tests/test_beesdoo_shift.py +++ b/beesdoo_shift/tests/test_beesdoo_shift.py @@ -260,6 +260,7 @@ class TestBeesdooShift(TransactionCase): self.user_generic )._generate_attendance_sheet() sheet_1 = self.search_sheets(self.start_in_1, self.end_in_1,) + sheet_1 = sheet_1.sudo(self.user_generic) """ Expected workers are : @@ -357,14 +358,6 @@ 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: - sheet_1.validate_with_checks() - self.assertIn("wait", str(e.exception)) - time.sleep(waiting_time) - # TODO: test validation with wizard (as generic user) # class odoo.tests.common.Form(recordp, view=None) # is only available from version 12 @@ -373,6 +366,15 @@ class TestBeesdooShift(TransactionCase): # Validation without wizard (as admin user) sheet_1 = sheet_1.sudo(self.user_admin) + + # 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: + sheet_1.validate_with_checks() + self.assertIn("wait", str(e.exception)) + time.sleep(waiting_time) + sheet_1.worker_nb_feedback = "enough" sheet_1.feedback = "Great session." sheet_1.notes = "Important information." diff --git a/beesdoo_shift/views/attendance_sheet.xml b/beesdoo_shift/views/attendance_sheet.xml index 3b04c81..6e843f8 100644 --- a/beesdoo_shift/views/attendance_sheet.xml +++ b/beesdoo_shift/views/attendance_sheet.xml @@ -148,11 +148,11 @@