Merge pull request #5793 from expsa/bakry_hr

fix holiday
This commit is contained in:
bakry 2025-12-23 13:06:41 +03:00 committed by GitHub
commit cb2001662d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 10 deletions

View File

@ -487,14 +487,16 @@ class HRHolidays(models.Model):
last_date = datetime.strftime(today, "{0}-12-31".format(years))
last_date = datetime.strptime(str(last_date), "%Y-%m-%d").date()
start_days = last_date - timedelta(days=int(holiday.remained_before))
if today < last_date:
if start_days <= today < last_date:
if today.weekday() != 6: # Send on Sunday only, not every day
return
balance = self.env['hr.holidays'].search([('employee_id', '=', emp.id),
('holiday_status_id', '=', holiday.id),
('type', '=', 'add'),
('check_allocation_view', '=', 'balance')
], limit=1, order="id desc")
holi_balance = balance.remaining_leaves or 0.0
if today >= start_days < last_date:
if holi_balance > holiday.number_of_save_days:
if emp.user_id:
template = self.env.ref('hr_holidays_public.email_template_holiday_balance', False)