fix holiday

This commit is contained in:
Bakry 2025-12-21 17:01:48 +03:00
parent 0da086450d
commit 9eefc082cd
1 changed files with 3 additions and 2 deletions

View File

@ -1622,20 +1622,21 @@ class HRHolidays(models.Model):
"""chick a holiday take balance with years balance""" """chick a holiday take balance with years balance"""
for item in self: for item in self:
holiday_days = item.number_of_days_temp holiday_days = item.number_of_days_temp
holiday_type = item.holiday_status_id.leave_type
employee_balance = self.env['hr.holidays'].search([('employee_id', '=', item.employee_id.id), employee_balance = self.env['hr.holidays'].search([('employee_id', '=', item.employee_id.id),
('holiday_status_id', '=', item.holiday_status_id.id), ('holiday_status_id', '=', item.holiday_status_id.id),
('type', '=', 'add'), ('type', '=', 'add'),
('check_allocation_view', '=', 'balance')], ('check_allocation_view', '=', 'balance')],
order='id desc', limit=1) order='id desc', limit=1)
leave_type = ['exam', 'marriage','parental','emergency','sick'] leave_type = ['exam', 'marriage','parental','emergency','sick']
if item.holiday_status_id.leave_type in leave_type: if holiday_type in leave_type:
cron_run_date = item.employee_id.first_hiring_date cron_run_date = item.employee_id.first_hiring_date
holi_date_from = fields.Date.from_string(item.date_from) holi_date_from = fields.Date.from_string(item.date_from)
holi_date_to = fields.Date.from_string(item.date_to) holi_date_to = fields.Date.from_string(item.date_to)
if employee_balance.holiday_ids: if employee_balance.holiday_ids:
cron_run_date = employee_balance.holiday_ids[-1].cron_run_date cron_run_date = employee_balance.holiday_ids[-1].cron_run_date
if cron_run_date > holi_date_to: if (holiday_type=='sick' and cron_run_date > holi_date_to) or (cron_run_date.year > holi_date_to.year):
holiday_days = 0 holiday_days = 0
if holi_date_to >= cron_run_date > holi_date_from: if holi_date_to >= cron_run_date > holi_date_from:
holiday_days = (holi_date_to - cron_run_date).days+1 holiday_days = (holi_date_to - cron_run_date).days+1