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)])