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 @@
+