From 57426523be080a14097b7b9723bd68500109d913 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: Wed, 19 Aug 2026 16:10:33 +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 --- .../models/yuthon_vacation_reports.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index add75d2d9..8c1749ec8 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -1121,19 +1121,25 @@ class YuthonVacationReports(models.Model): if att.is_abnormal: is_abnormal += 1 # 5. 计算应到天数(适配外派) - # 取员工最早的合同(含已中止),从最早入职时间开始统计应到天数 - contract = self.env['hr.contract'].search([ + # 开始时间:取员工最早的合同(含已中止)的 date_start + # 结束时间:取运行中(state='open')合同的 date_end + earliest_contract = self.env['hr.contract'].search([ ('employee_id', '=', employee.id), ], order='date_start asc, id asc', limit=1) + running_contract = self.env['hr.contract'].search([ + ('employee_id', '=', employee.id), + ('state', '=', 'open'), + ], order='date_end desc, id desc', limit=1) if is_outside: if exp_has_return and exp_end_return: work_days = rec._create_leave_record(employee, exp_end_return + timedelta(days=1), month_end) else: work_days = 0 else: - start_date = max(contract.date_start, month_start) if ( - contract and contract.date_start) else month_start - end_date = min(contract.date_end, month_end) if (contract and contract.date_end) else month_end + start_date = max(earliest_contract.date_start, month_start) if ( + earliest_contract and earliest_contract.date_start) else month_start + end_date = min(running_contract.date_end, month_end) if ( + running_contract and running_contract.date_end) else month_end work_days = rec._create_leave_record(employee, start_date, end_date) # 6. 计算试用期/转正天数