Browse Source

[IMP] b_shift : attendance sheet max worker no calculation

Now based on created shifts instead of task templates
pull/125/head
Elouan Le Bars 5 years ago
parent
commit
7a75fa04a4
  1. 11
      beesdoo_shift/models/attendance_sheet.py
  2. 4
      beesdoo_shift/views/attendance_sheet.xml

11
beesdoo_shift/models/attendance_sheet.py

@ -188,7 +188,8 @@ class AttendanceSheet(models.Model):
string="Maximum number of workers",
default=0,
readonly=True,
help="Indicative maximum number of workers for the shifts.",
help="Indicative maximum number of workers.",
)
annotation = fields.Text("Annotation", default="")
is_annotated = fields.Boolean(
@ -379,6 +380,7 @@ class AttendanceSheet(models.Model):
# Creation and addition of the expected shifts corresponding
# to the time range
tasks = self.env["beesdoo.shift.shift"]
expected_shift = self.env["beesdoo.shift.sheet.expected"]
cancelled_stage = self.env.ref("beesdoo_shift.cancel")
s_time = fields.Datetime.from_string(new_sheet.start_time)
e_time = fields.Datetime.from_string(new_sheet.end_time)
@ -392,8 +394,6 @@ class AttendanceSheet(models.Model):
("end_time", "<", fields.Datetime.to_string(e_time + delta)),
]
)
expected_shift = self.env["beesdoo.shift.sheet.expected"]
task_templates = set()
for task in tasks:
if task.working_mode == "irregular":
stage = "absent_1"
@ -412,9 +412,8 @@ class AttendanceSheet(models.Model):
"working_mode": task.working_mode,
}
)
task_templates.add(task.task_template_id)
# Maximum number of workers calculation
new_sheet.max_worker_no = sum(r.worker_nb for r in task_templates)
# Maximum number of workers calculation (count empty shifts)
new_sheet.max_worker_no = len(tasks)
return new_sheet
@api.multi

4
beesdoo_shift/views/attendance_sheet.xml

@ -157,13 +157,15 @@
<field name="time_slot" />
</h1>
</div>
<group>
<field name="max_worker_no" />
</group>
<separator string="Added workers" />
<field name="added_shift_ids"/>
<separator string="Expected workers" />
<field name="expected_shift_ids" />
<group string="Informations">
<field name="default_super_coop_id" />
<field name="max_worker_no" />
</group>
<br/>
<group col="1" string="Feedback"

Loading…
Cancel
Save