From e05a9dd62cc3ccc77695d619e2fa2bbe74464b5a Mon Sep 17 00:00:00 2001 From: Bakry Date: Tue, 23 Dec 2025 12:52:57 +0300 Subject: [PATCH] fix holiday --- .../hr_holidays_public/models/hr_holidays.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/odex25_hr/hr_holidays_public/models/hr_holidays.py b/odex25_hr/hr_holidays_public/models/hr_holidays.py index a635cb4ec..3d14f5a02 100644 --- a/odex25_hr/hr_holidays_public/models/hr_holidays.py +++ b/odex25_hr/hr_holidays_public/models/hr_holidays.py @@ -487,20 +487,22 @@ 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: - balance = self.env['hr.holidays'].search([('employee_id', '=', emp.id), + + 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) - template.write({'email_to': emp.user_id.partner_id.email, 'lang': emp.user_id.lang, - 'email_cc': '%s' % (self.env.user.company_id.hr_email)}) - template.send_mail(balance.id) + holi_balance = balance.remaining_leaves or 0.0 + if holi_balance > holiday.number_of_save_days: + if emp.user_id: + template = self.env.ref('hr_holidays_public.email_template_holiday_balance', False) + template.write({'email_to': emp.user_id.partner_id.email, 'lang': emp.user_id.lang, + 'email_cc': '%s' % (self.env.user.company_id.hr_email)}) + template.send_mail(balance.id) if holiday.payslip_type == 'unpaid': tomorrow = (fields.Datetime.from_string(fields.Datetime.now()) + timedelta(days=1)).strftime( '%Y-%m-%d 00:00:00')