From 2ff053b78c562e062c890b2d2c797ebb60a0ef1c Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Tue, 18 Mar 2025 11:04:04 +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 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/yuthon_hr_attendance/models/yuthon_duty_plan.py b/yuthon_hr_attendance/models/yuthon_duty_plan.py index 88fe5308d..e9c61f15e 100644 --- a/yuthon_hr_attendance/models/yuthon_duty_plan.py +++ b/yuthon_hr_attendance/models/yuthon_duty_plan.py @@ -66,10 +66,17 @@ class YuthonDutyPlan(models.Model): first_day_of_month = datetime(next_year, 1, 1) last_day_of_month = datetime(next_year,2, 1) else: - first_day_of_month = datetime(next_year, latest_month+1, 1) - next_next_month = (latest_month % 12) + 1 - next_year = year + (1 if next_month == 1 else 0) - last_day_of_month = datetime(next_year, next_next_month+1, 1) + next_year = latest_year + next_month = latest_month + 1 + first_day_of_month = datetime(next_year, next_month, 1) + # 计算下下一个月的第一天 + if next_month == 12: + next_next_year = next_year + 1 + next_next_month = 1 + else: + next_next_year = next_year + next_next_month = next_month + 1 + last_day_of_month = datetime(next_next_year, next_next_month, 1) role_a = self.env['planning.role'].search([('name', '=', '联安粮库')], limit=1) role_template_a = self.env['planning.slot.template'].search([('planning_name', '=', '白班'), ('role_id', '=', role_a.id)]) role_template_b = self.env['planning.slot.template'].search([('planning_name', '=', '白值'), ('role_id', '=', role_a.id)])