Browse Source

[FIX] b_shift : attendance sheet shifts worker not required

pull/143/head
Elouan Le Bars 5 years ago
parent
commit
ea0bb5d047
  1. 30
      beesdoo_shift/models/attendance_sheet.py

30
beesdoo_shift/models/attendance_sheet.py

@ -46,7 +46,6 @@ class AttendanceSheetShift(models.Model):
("working_mode", "in", ("regular", "irregular")), ("working_mode", "in", ("regular", "irregular")),
("state", "not in", ("unsubscribed", "resigning")), ("state", "not in", ("unsubscribed", "resigning")),
], ],
required=True,
) )
task_type_id = fields.Many2one( task_type_id = fields.Many2one(
"beesdoo.shift.type", string="Task Type", default=_default_task_type_id "beesdoo.shift.type", string="Task Type", default=_default_task_type_id
@ -342,20 +341,21 @@ class AttendanceSheet(models.Model):
compensation_nb = "1" compensation_nb = "1"
else: else:
compensation_nb = "2" compensation_nb = "2"
new_expected_shift = expected_shift.create(
{
"attendance_sheet_id": new_sheet.id,
"task_id": task.id,
"worker_id": task.worker_id.id,
"replacement_worker_id": task.replaced_id.id,
"task_type_id": task.task_type_id.id,
"stage": "absent",
"compensation_nb": compensation_nb,
"working_mode": task.working_mode,
}
)
task_templates.add(task.task_template_id)
new_sheet.expected_worker_nb += 1
if task.worker_id:
new_expected_shift = expected_shift.create(
{
"attendance_sheet_id": new_sheet.id,
"task_id": task.id,
"worker_id": task.worker_id.id,
"replacement_worker_id": task.replaced_id.id,
"task_type_id": task.task_type_id.id,
"stage": "absent",
"compensation_nb": compensation_nb,
"working_mode": task.working_mode,
}
)
task_templates.add(task.task_template_id)
new_sheet.expected_worker_nb += 1
# Maximum number of workers calculation # Maximum number of workers calculation
for task_template in task_templates: for task_template in task_templates:
new_sheet.max_worker_nb += task_template.worker_nb new_sheet.max_worker_nb += task_template.worker_nb

Loading…
Cancel
Save