Browse Source

[IMP] b_shift : attendance annotation pre-filled on wizard

pull/143/head
Elouan Le Bars 5 years ago
parent
commit
7ece3f34ed
  1. 13
      beesdoo_shift/models/attendance_sheet.py
  2. 28
      beesdoo_shift/wizard/validate_attendance_sheet.py

13
beesdoo_shift/models/attendance_sheet.py

@ -478,18 +478,7 @@ class AttendanceSheet(models.Model):
) )
is_regular_worker = added_shift.worker_id.working_mode == "regular" is_regular_worker = added_shift.worker_id.working_mode == "regular"
is_regular_shift = added_shift.regular_task_type == "normal" is_regular_shift = added_shift.regular_task_type == "normal"
if is_regular_shift and is_regular_worker:
warning_message = (
_(
"\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 # Edit a non-assigned shift or create one if none
non_assigned_shifts = shift.search( non_assigned_shifts = shift.search(
[ [

28
beesdoo_shift/wizard/validate_attendance_sheet.py

@ -9,10 +9,36 @@ class ValidateAttendanceSheet(models.TransientModel):
Useless for users in group_cooperative_admin""" Useless for users in group_cooperative_admin"""
_inherit = ["barcodes.barcode_events_mixin"] _inherit = ["barcodes.barcode_events_mixin"]
@api.multi
def _default_annotation(self):
"""
The annotation is pre-filled with a warning message
if a regular worker is added and should have been expected.
"""
sheet_id = self._context.get("active_id")
sheet_model = self._context.get("active_model")
sheet = self.env[sheet_model].browse(sheet_id)
warning_message = ""
for added_shift in sheet.added_shift_ids:
is_regular_worker = added_shift.worker_id.working_mode == "regular"
is_regular_shift = added_shift.regular_task_type == "normal"
if is_regular_shift and is_regular_worker:
warning_message += (
_(
"Warning : %s attended its shift as a normal one but was not expected. "
"Something may be wrong in his/her personnal informations.\n\n"
)
% added_shift.worker_id.name
)
return warning_message
barcode = fields.Char(string="Barcode", required=True) barcode = fields.Char(string="Barcode", required=True)
annotation = fields.Text( annotation = fields.Text(
"Important information requiring permanent member assistance", "Important information requiring permanent member assistance",
default="",
default=_default_annotation,
) )
feedback = fields.Text("General feedback") feedback = fields.Text("General feedback")
worker_nb_feedback = fields.Selection( worker_nb_feedback = fields.Selection(

Loading…
Cancel
Save