From c7568c06818ea5cda6f828870fcfb1418be55d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Tue, 7 Jul 2026 11:24:31 +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/go_approval.py | 15 +++++++++++++++ .../models/overtime_approval.py | 19 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/yuthon_hr_attendance/models/go_approval.py b/yuthon_hr_attendance/models/go_approval.py index 1e16b8c21..1ba981ec6 100644 --- a/yuthon_hr_attendance/models/go_approval.py +++ b/yuthon_hr_attendance/models/go_approval.py @@ -4,6 +4,7 @@ from datetime import datetime, time, timedelta from odoo.exceptions import UserError from odoo.exceptions import ValidationError, UserError import calendar +from dateutil.relativedelta import relativedelta class GoApprovalsLine(models.Model): @@ -321,6 +322,20 @@ class GoApprovals(models.Model): ('vacation_date', '=', month_first) ], limit=1) + # 如果当月考勤确认单已确认,则将数据加到下个月的确认单 + if reports_id and reports_id.vacation_state == 'confirmed': + next_month_first = month_first + relativedelta(months=1) + reports_id = self.env['yuthon.vacation.reports'].search([ + ('employee_id', '=', self.users_id.employee_ids.id), + ('vacation_date', '=', next_month_first) + ], limit=1) + if not reports_id: + reports_id = self.env['yuthon.vacation.reports'].create({ + 'employee_id': self.users_id.employee_ids.id, + 'vacation_date': next_month_first, + }) + reports_id.vacation_state = 'not_sent' + if not reports_id: continue diff --git a/yuthon_hr_attendance/models/overtime_approval.py b/yuthon_hr_attendance/models/overtime_approval.py index 9ca615ad5..2ed3a98ea 100644 --- a/yuthon_hr_attendance/models/overtime_approval.py +++ b/yuthon_hr_attendance/models/overtime_approval.py @@ -416,7 +416,6 @@ class OvertimeApprovals(models.Model): else: start_date = datetime(start_year, 1, 1).date() valid_date = False - meal_number = employee_id.meal_number if self.meal == 'yes': meal_number += 1 @@ -430,6 +429,21 @@ class OvertimeApprovals(models.Model): ('employee_id', '=', employee_id.id), ('vacation_date', '=', vacation_date) ]) + + # 如果当月考勤确认单已确认,则将数据加到下个月的确认单 + if reports_id and reports_id.vacation_state == 'confirmed': + next_month_date = vacation_date + relativedelta(months=1) + reports_id = self.env['yuthon.vacation.reports'].search([ + ('employee_id', '=', employee_id.id), + ('vacation_date', '=', next_month_date) + ], limit=1) + if not reports_id: + reports_id = self.env['yuthon.vacation.reports'].create({ + 'employee_id': employee_id.id, + 'vacation_date': next_month_date, + }) + reports_id.vacation_state = 'not_sent' + workflow_record_id = self.env['soong.workflow.record'].search([ ('code', '=', self.code), ('reclaim_state', '=', False) @@ -498,6 +512,9 @@ class OvertimeApprovals(models.Model): }) reports_id.write({'meal_fee_ids': [meal_fee_value]}) + + + start_date = fields.Date.to_date(self.start_time) end_date = fields.Date.to_date(self.end_time) attendance_records = self.env['hr.attendance'].search([