From 3ef2976821311e2f342652e87978211b51234bd5 Mon Sep 17 00:00:00 2001 From: Elouan Le Bars Date: Mon, 9 Dec 2019 16:09:32 +0100 Subject: [PATCH] [ADD] b_shift : exception raised when replaced worker try to subscribe --- beesdoo_shift/models/attendance_sheet.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/beesdoo_shift/models/attendance_sheet.py b/beesdoo_shift/models/attendance_sheet.py index 353f1af..27411bb 100644 --- a/beesdoo_shift/models/attendance_sheet.py +++ b/beesdoo_shift/models/attendance_sheet.py @@ -320,7 +320,6 @@ class AttendanceSheet(models.Model): ) def on_barcode_scanned(self, barcode): - if self.state == "validated": raise UserError( _("You cannot modify a validated attendance sheet.") @@ -345,11 +344,14 @@ class AttendanceSheet(models.Model): for id in self.expected_shift_ids.ids: shift = self.env["beesdoo.shift.sheet.expected"].browse(id) if ( - shift.worker_id == worker - or shift.replacement_worker_id == worker - ): + shift.worker_id == worker and not shift.replacement_worker_id + ) or shift.replacement_worker_id == worker: shift.stage = "present" return + if shift.worker_id == worker and shift.replacement_worker_id: + raise UserError( + _("%s was expected as replaced.") % worker.name + ) if worker.working_mode == "regular": regular_task_type = "compensation"