diff --git a/yuthon_holiday/models/inherit_hr_leave.py b/yuthon_holiday/models/inherit_hr_leave.py index 3e550dc14..fd3a10504 100644 --- a/yuthon_holiday/models/inherit_hr_leave.py +++ b/yuthon_holiday/models/inherit_hr_leave.py @@ -236,6 +236,20 @@ class HrLeave(models.Model): employee.write({ 'user_year': employee.user_year - days }) + + elif record.employee_id and record.holiday_status_id.name == '补休': + employee = record.employee_id + days = record.number_of_hours_display + over_lines_to_delete = self.env['vacation.over.line'].search([ + ('employee_id', '=', employee.id), + ('workday', '=', days), + ('update_type', '=', 'reduce'), + ('text', 'ilike', f'%{record.name}%'), # 通过名称模糊匹配 + ]) + + if over_lines_to_delete: + over_lines_to_delete.write({'is_void': True}) + return super(HrLeave, self).unlink() @api.depends('request_hour_from')