From d4ed673f820434594cd41f78435855f4d7b47147 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, 10 Sep 2025 17:18:47 +0800 Subject: [PATCH 1/2] =?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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index d197c8ed2..8e66ced5a 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -147,7 +147,16 @@ class YuthonVacationReports(models.Model): month_start = date(year, month, 1) month_end = date(year, month, days_in_month) leave_days = rec._create_leave_record(rec.employee_id, month_start, month_end) - for day in range(1, days_in_month + 1): + entry_date = rec.employee_id.entry_date + actual_start_date = max(month_start, entry_date) if entry_date else month_start + if not entry_date: + start_day = 1 + else: + days_in_month = (date(year, month + 1, 1) - timedelta(days=1)).day + start_day = min(actual_start_date.day, days_in_month) + days_in_month = (date(year, month + 1, 1) - timedelta(days=1)).day + actual_days_range = range(start_day, days_in_month + 1) + for day in actual_days_range: current_date = date(year, month, day) attendances = self.env["hr.attendance"].sudo().search([ ('employee_id', '=', rec.employee_id.id), From 309c78bbef3e675d95181993ac168c513864f435 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, 10 Sep 2025 17:21:44 +0800 Subject: [PATCH 2/2] =?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_vacation_reports.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index 8e66ced5a..9cde87af2 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -148,12 +148,11 @@ class YuthonVacationReports(models.Model): month_end = date(year, month, days_in_month) leave_days = rec._create_leave_record(rec.employee_id, month_start, month_end) entry_date = rec.employee_id.entry_date - actual_start_date = max(month_start, entry_date) if entry_date else month_start - if not entry_date: + if month_start > entry_date: start_day = 1 else: days_in_month = (date(year, month + 1, 1) - timedelta(days=1)).day - start_day = min(actual_start_date.day, days_in_month) + start_day = min(entry_date.day, days_in_month) days_in_month = (date(year, month + 1, 1) - timedelta(days=1)).day actual_days_range = range(start_day, days_in_month + 1) for day in actual_days_range: