From f7b615cb8267e761944110291c96204667c873c2 Mon Sep 17 00:00:00 2001 From: Elouan Le Bars Date: Tue, 10 Dec 2019 18:45:15 +0100 Subject: [PATCH] [IMP] b_shift : cooperative admin can validate sheet with their cards --- beesdoo_shift/wizard/validate_attendance_sheet.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/beesdoo_shift/wizard/validate_attendance_sheet.py b/beesdoo_shift/wizard/validate_attendance_sheet.py index 9d155a3..3bec511 100644 --- a/beesdoo_shift/wizard/validate_attendance_sheet.py +++ b/beesdoo_shift/wizard/validate_attendance_sheet.py @@ -36,8 +36,11 @@ class ValidateAttendanceSheet(models.TransientModel): card = self.env["member.card"].search([("barcode", "=", self.barcode)]) if not len(card): raise UserError(_("Please set a correct barcode.")) - user = card[0].partner_id - if not user.super: + partner = card[0].partner_id + is_admin = partner.user_ids.has_group( + "beesdoo_shift.group_cooperative_admin" + ) + if not partner.super and not is_admin: raise UserError( _( "Only super-cooperators and administrators can validate attendance sheets." @@ -48,4 +51,4 @@ class ValidateAttendanceSheet(models.TransientModel): if sheet.feedback: sheet.feedback += self.feedback sheet.worker_nb_feedback = self.worker_nb_feedback - sheet.validate(user or self.env.user.partner_id) + sheet.validate(partner or self.env.user.partner_id)