diff --git a/yuthon_hr_attendance/models/overtime_approval.py b/yuthon_hr_attendance/models/overtime_approval.py index 584af9a7b..c4f7414f6 100644 --- a/yuthon_hr_attendance/models/overtime_approval.py +++ b/yuthon_hr_attendance/models/overtime_approval.py @@ -117,17 +117,17 @@ class OvertimeApprovals(models.Model): continue # 一个月加班时长不能超过36小时 - first_day = rec.start_time.replace(day=1, hour=0, minute=0, second=0, microsecond=0) + first_day = rec.start_time.date().replace(day=1) vacation_report = self.env['yuthon.vacation.reports'].search([ ('employee_id', '=', employee.id), - ('vacation_date', '==', first_day), + ('vacation_date', '=', first_day), ], limit=1) - cop_leave = vacation_report.cop_leave if vacation_report else 0.0 + cop_leave = vacation_report.done_working_overtime * 8 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 小时上限!' + message = f'本月已加班时长已超过 36 小时' raise ValidationError(message) else: rec.duration = calculated_hours diff --git a/yuthon_hr_attendance/views/overtime_approval.xml b/yuthon_hr_attendance/views/overtime_approval.xml index 785807dff..c158b634b 100644 --- a/yuthon_hr_attendance/views/overtime_approval.xml +++ b/yuthon_hr_attendance/views/overtime_approval.xml @@ -72,7 +72,7 @@