diff --git a/beesdoo_shift/models/attendance_sheet.py b/beesdoo_shift/models/attendance_sheet.py index 10aefaf..5e86c63 100644 --- a/beesdoo_shift/models/attendance_sheet.py +++ b/beesdoo_shift/models/attendance_sheet.py @@ -73,7 +73,7 @@ class AttendanceSheetShift(models.AbstractModel): """ if not self.working_mode or not self.stage: raise UserError( - _("Impossible to map task status, all values are not set.") + _("Impossible to map task stage, all values are not set.") ) if self.working_mode == "regular": if self.stage == "present": @@ -157,7 +157,7 @@ class AttendanceSheet(models.Model): active = fields.Boolean(string="Active", default=1) state = fields.Selection( [("not_validated", "Not Validated"), ("validated", "Validated"),], - string="Status", + string="State", readonly=True, index=True, default="not_validated", @@ -213,13 +213,7 @@ class AttendanceSheet(models.Model): ("enough", "Enough"), ("too_many", "Too many"), ], - string="Number of workers.", - ) - attended_worker_nb = fields.Integer( - string="Number of attended workers", - default=0, - help="Number of workers who attended the session.", - readonly=True, + string="Number of workers", ) validated_by = fields.Many2one( "res.partner", @@ -385,7 +379,7 @@ class AttendanceSheet(models.Model): return self.search_count(domain) return - def validate(self): + def validate(self, user): self.ensure_one() if self.state == "validated": raise UserError("The sheet has already been validated.") @@ -500,6 +494,7 @@ class AttendanceSheet(models.Model): ) added_shift.task_id = actual_shift.id + self.validated_by = user self.state = "validated" return diff --git a/beesdoo_shift/wizard/validate_attendance_sheet.py b/beesdoo_shift/wizard/validate_attendance_sheet.py index 1f2aec8..9f2d236 100644 --- a/beesdoo_shift/wizard/validate_attendance_sheet.py +++ b/beesdoo_shift/wizard/validate_attendance_sheet.py @@ -34,7 +34,7 @@ class ValidateAttendanceSheet(models.TransientModel): if not len(card): raise UserError(_("Please set a correct barcode.")) user = card[0].partner_id - if not user: + if not user.super: raise UserError( _( "Only super-cooperators and administrators can validate attendance sheets." @@ -43,8 +43,7 @@ class ValidateAttendanceSheet(models.TransientModel): sheet.annotation = self.annotation sheet.feedback = self.feedback sheet.worker_nb_feedback = self.worker_nb_feedback - sheet.validated_by = user - sheet.validate() + sheet.validate(user or self.env.user.partner_id) def on_barcode_scanned(self, barcode): self.barcode = barcode diff --git a/beesdoo_shift/wizard/validate_attendance_sheet.xml b/beesdoo_shift/wizard/validate_attendance_sheet.xml index ee7ffbf..3256124 100644 --- a/beesdoo_shift/wizard/validate_attendance_sheet.xml +++ b/beesdoo_shift/wizard/validate_attendance_sheet.xml @@ -10,14 +10,14 @@ and you won't be able to add any latecomers. Emails will be sent to workers who did not attend their shift." /> - + - +