From d60e4f4556d51dedd85108946bd7dd80ee2a8e49 Mon Sep 17 00:00:00 2001 From: Elouan Le Bars Date: Wed, 4 Dec 2019 12:12:01 +0100 Subject: [PATCH] [FIX] b_shift : attendance sheet annotation validation --- beesdoo_shift/models/attendance_sheet.py | 16 +++++++++------- .../wizard/validate_attendance_sheet.py | 6 ++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/beesdoo_shift/models/attendance_sheet.py b/beesdoo_shift/models/attendance_sheet.py index 5e86c63..1ced0c8 100644 --- a/beesdoo_shift/models/attendance_sheet.py +++ b/beesdoo_shift/models/attendance_sheet.py @@ -327,8 +327,7 @@ class AttendanceSheet(models.Model): @api.depends("annotation") def _compute_is_annotated(self): for rec in self: - if rec.annotation: - rec.is_annotated = len(rec.annotation) != 0 + rec.is_annotated = (rec.annotation.strip() != False) @api.model def create(self, vals): @@ -448,13 +447,17 @@ class AttendanceSheet(models.Model): is_regular_shift = added_shift.regular_task_type == "normal" # Add an annotation if a regular worker is doing its regular shift if is_regular_shift and is_regular_worker: - self.annotation += ( + warning_message = ( _( - "\n\nWarning : %s attended its shift as a normal one but was not expected." + "\nWarning : %s attended its shift as a normal one but was not expected." " Something may be wrong in his/her personnal informations.\n" ) % added_shift.worker_id.name ) + if self.annotation: + self.annotation += warning_message + else: + self.annotation = warning_message # Edit a non-assigned shift or create one if none non_assigned_shifts = shift.search( [ @@ -499,12 +502,11 @@ class AttendanceSheet(models.Model): return # @api.multi is needed to call the wizard, but doesn't match @api.one - # from the validate() method + # from the validate(user) method @api.multi def validate_via_wizard(self): if self.env.user.has_group("beesdoo_shift.group_cooperative_admin"): - self.validated_by = self.env.user.partner_id - self.validate() + self.validate(self.env.user.partner_id) return return { "type": "ir.actions.act_window", diff --git a/beesdoo_shift/wizard/validate_attendance_sheet.py b/beesdoo_shift/wizard/validate_attendance_sheet.py index 9f2d236..f840b76 100644 --- a/beesdoo_shift/wizard/validate_attendance_sheet.py +++ b/beesdoo_shift/wizard/validate_attendance_sheet.py @@ -40,8 +40,10 @@ class ValidateAttendanceSheet(models.TransientModel): "Only super-cooperators and administrators can validate attendance sheets." ) ) - sheet.annotation = self.annotation - sheet.feedback = self.feedback + if self.annotation: + sheet.annotation += self.annotation + if sheet.feedback: + sheet.feedback += self.feedback sheet.worker_nb_feedback = self.worker_nb_feedback sheet.validate(user or self.env.user.partner_id)