Skip to content

Commit

Permalink
[IMP] hr_holidays_summary_email: don't send empty summaries
Browse files Browse the repository at this point in the history
  • Loading branch information
MiquelRForgeFlow committed Nov 25, 2024
1 parent d09c1a6 commit 31af8fd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions hr_holidays_summary_email/models/hr_leave.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _cron_send_hr_leave_summary_emails_daily(self, employees_to_notify, company)
domain = self._get_hr_leave_summary_daily_domain(company.id)
today_time_offs = self.env["hr.leave"].sudo().search(domain)
template = self._get_hr_leave_summary_mail_template("daily")
if not template:
if not template or not today_time_offs:
return
for employee in employees_to_notify:
template.with_context(time_offs=today_time_offs).send_mail(
Expand All @@ -71,12 +71,12 @@ def _cron_send_hr_leave_summary_emails_weekly(self, employees_to_notify, company
if str(fields.Date.today().weekday()) != company.hr_holidays_summary_weekly_dow:
return
domain = self._get_hr_leave_summary_weekly_domain(company.id)
today_time_offs = self.env["hr.leave"].sudo().search(domain)
weekly_time_offs = self.env["hr.leave"].sudo().search(domain)
template = self._get_hr_leave_summary_mail_template("weekly")
if not template:
if not template or not weekly_time_offs:
return
for employee in employees_to_notify:
template.with_context(time_offs=today_time_offs).send_mail(
template.with_context(time_offs=weekly_time_offs).send_mail(
employee.id, force_send=False
)
employees_to_notify.write({"last_hr_leave_summary_sent": fields.Date.today()})
Expand Down

0 comments on commit 31af8fd

Please sign in to comment.