From 7a75fa04a43b8c7517fcd98280643d8feb3f3576 Mon Sep 17 00:00:00 2001 From: Elouan Le Bars Date: Tue, 10 Dec 2019 15:40:52 +0100 Subject: [PATCH] [IMP] b_shift : attendance sheet max worker no calculation Now based on created shifts instead of task templates --- beesdoo_shift/models/attendance_sheet.py | 11 +++++------ beesdoo_shift/views/attendance_sheet.xml | 4 +++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/beesdoo_shift/models/attendance_sheet.py b/beesdoo_shift/models/attendance_sheet.py index 1a653c7..a092e30 100644 --- a/beesdoo_shift/models/attendance_sheet.py +++ b/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 diff --git a/beesdoo_shift/views/attendance_sheet.xml b/beesdoo_shift/views/attendance_sheet.xml index afaa824..89e21dd 100644 --- a/beesdoo_shift/views/attendance_sheet.xml +++ b/beesdoo_shift/views/attendance_sheet.xml @@ -157,13 +157,15 @@ + + + -