Browse Source

[FIX] b_shift : attendance sheet annotation validation

pull/143/head
Elouan Le Bars 5 years ago
parent
commit
6b3a9ed777
  1. 16
      beesdoo_shift/models/attendance_sheet.py
  2. 6
      beesdoo_shift/wizard/validate_attendance_sheet.py

16
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",

6
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)

Loading…
Cancel
Save