From bb7bb55c15be87817d14f83c98f950bd1003d139 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: Fri, 18 Sep 2026 10:35:22 +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_holiday/models/inherit_hr_leave.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/yuthon_holiday/models/inherit_hr_leave.py b/yuthon_holiday/models/inherit_hr_leave.py index 509b1ae1d..a245038b7 100644 --- a/yuthon_holiday/models/inherit_hr_leave.py +++ b/yuthon_holiday/models/inherit_hr_leave.py @@ -236,6 +236,9 @@ class HrLeave(models.Model): holiday.number_of_hours = 4 else: hour = end_hour - start_hour + # 跨中午(12:00-13:00 午休),减去1小时 + if start_hour < 13 and end_hour > 12: + hour -= 1 holiday.number_of_hours = hour else: holiday.number_of_hours = 0 @@ -268,7 +271,11 @@ class HrLeave(models.Model): if start_hour == 9 and end_hour in [13, 14]: self.leave_hours = 4 else: - self.leave_hours = end_hour - start_hour + leave_hours = end_hour - start_hour + # 跨中午(12:00-13:00 午休),减去1小时 + if start_hour < 13 and end_hour > 12: + leave_hours -= 1 + self.leave_hours = leave_hours else: self.leave_hours = 0 @@ -538,8 +545,7 @@ class HolidaysRequestBatch(models.Model): hourly_records = [] for line in self.hour_leave_ids: if line.holiday_status_id.name == leave_type_name and line.request_date_from: - hours_match = re.search(r'(\d+(?:\.\d+)?)', line.number_of_hours_text or '') - hours = float(hours_match.group(1)) if hours_match else 0 + hours = line.leave_hours hourly_records.append({ 'leave_id': line.id, 'date': fields.Date.from_string(line.request_date_from),