From d2a465ef535487f114c8f1f3425be36c5302e45b 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: Thu, 18 Sep 2025 17:02:23 +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/overtime_approval.py | 22 +++++++++++++++++++ .../views/property_lease_contract.xml | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/yuthon_hr_attendance/models/overtime_approval.py b/yuthon_hr_attendance/models/overtime_approval.py index e88f03ecb..e99d4821b 100644 --- a/yuthon_hr_attendance/models/overtime_approval.py +++ b/yuthon_hr_attendance/models/overtime_approval.py @@ -66,6 +66,7 @@ class OvertimeApprovals(models.Model): 'domain': domain, } + @api.onchange('users_id', 'start_time') def _onchange_att(self): if self.users_id and self.start_time: @@ -110,6 +111,27 @@ class OvertimeApprovals(models.Model): max_hours = 8.0 rec.duration = min(calculated_hours, max_hours) + employee = rec.user_id.employee_id + if not employee: + rec.duration = calculated_hours + continue + + # 一个月加班时长不能超过36小时 + first_day = rec.start_time.replace(day=1, hour=0, minute=0, second=0, microsecond=0) + vacation_report = self.env['yuthon.vacation.reports'].search([ + ('employee_id', '=', employee.id), + ('vacation_date', '==', first_day), + ], limit=1) + + cop_leave = vacation_report.cop_leave if vacation_report else 0.0 + leave_hours = calculated_hours + if cop_leave + leave_hours > 36: + rec.duration = 0.0 + message = f'本月已请假 {cop_leave} 小时,超过 36 小时上限!' + raise ValidationError(message) + else: + rec.duration = calculated_hours + @api.depends('start_time', 'end_time') def _compute_weekday(self): weekday_names = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'] diff --git a/yuthon_property_approval/views/property_lease_contract.xml b/yuthon_property_approval/views/property_lease_contract.xml index 0e83a94c9..be1c5a0c4 100644 --- a/yuthon_property_approval/views/property_lease_contract.xml +++ b/yuthon_property_approval/views/property_lease_contract.xml @@ -4,7 +4,7 @@ property.lease.contract.tree property.lease.contract - + @@ -370,6 +370,7 @@