From ad9c5029760863680bbfb4b34ebd4ac8a6d96ea8 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Mon, 6 Jan 2025 19:35:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_hr_attendance/models/yuthon_duty_plan.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/yuthon_hr_attendance/models/yuthon_duty_plan.py b/yuthon_hr_attendance/models/yuthon_duty_plan.py index 42a23d092..1de685f3d 100644 --- a/yuthon_hr_attendance/models/yuthon_duty_plan.py +++ b/yuthon_hr_attendance/models/yuthon_duty_plan.py @@ -97,7 +97,8 @@ class YuthonDutyPlan(models.Model): self.zu = zu if zu == len(self.plan_line_ids): zu = 0 - for employee in self.plan_line_ids[zu].employee_ids: + sorted_plan_line_ids = self.plan_line_ids.sorted(key=lambda r: r.sequence) + for employee in sorted_plan_line_ids[zu].employee_ids: employee_id = self.env['planning.slot'].search([('resource_id', '=', employee.resource_id.id), ('start_datetime', '>=', first_day_of_month), ('start_datetime', '<=', last_day_of_month)]).sorted('start_datetime') if i < len(employee_id): start_hour2 = int(role_template_b.start_time) @@ -116,6 +117,7 @@ class YuthonDutyPlan(models.Model): i += 1 zu += 1 current_date2 += timedelta(days=1) + else: i = 0 zu = self.zu +1 @@ -123,7 +125,8 @@ class YuthonDutyPlan(models.Model): while current_date2 <= last_day_of_month: if zu == len(self.plan_line_ids): zu = 0 - for employee in self.plan_line_ids[zu].employee_ids: + sorted_plan_line_ids = self.plan_line_ids.sorted(key=lambda r: r.sequence) + for employee in sorted_plan_line_ids[zu].employee_ids: employee_id = self.env['planning.slot'].search( [('resource_id', '=', employee.resource_id.id), ('start_datetime', '>=', first_day_of_month), ('start_datetime', '<=', last_day_of_month)]).sorted('start_datetime')