diff --git a/yuthon_holiday/models/inherit_hr_leave.py b/yuthon_holiday/models/inherit_hr_leave.py index 8951524db..42635c8a4 100644 --- a/yuthon_holiday/models/inherit_hr_leave.py +++ b/yuthon_holiday/models/inherit_hr_leave.py @@ -1235,19 +1235,20 @@ class HolidaysRequestBatch(models.Model): parental_leave_type = self.env['hr.leave.type'].search([('name', 'ilike', '育儿假')], limit=1) if parental_leave_type: allocation_records = self.env['hr.leave.allocation'].search([ - ('employee_id', '=', parental_leave_type.id), + ('employee_id', '=', employee.id), + ('holiday_status_id', '=', parental_leave_type.id), ('state', 'in', ['validate', 'done']), ('date_from', '<=', current_date), '|', ('date_to', '=', False), ('date_to', '>=', current_date) - ]) + ],limit=1) total_allocation = sum( alloc.number_of_days_display for alloc in allocation_records) if allocation_records else 0.0 used_parental_leave_list = self.env['hr.leave'].search([ ('employee_id', '=', employee.id), ('holiday_status_id', '=', parental_leave_type.id), ('state', 'in', ['validate', 'done']), - ('date_from', '<=', current_date), - ('date_to', '>=', current_date) + ('date_from', '>=', allocation_records.date_from), + ('date_to', '<=', allocation_records.date_to) ]) used_days = sum(leave.number_of_days_display for leave in used_parental_leave_list) if used_parental_leave_list else 0.0