HelloPlease Help me to solve this
I have to send email when custom_date_from - today date = 7 then send this email template->leave_email_template
and if custom_date_from - today =1 send this email template->leave_request_email_templateHere I have written method for this but i donot know where I am wrong emails are not sending
@api.model
def test_cron_job(self):
print("abcddddddddddddddddddddddddddddddddddddddddddd")
today = fields.Date.today()
custom_date = self.env['hr.holidays'].search([('custom_date_from', '>=', today)])
print("custom_date", custom_date)
for rec in custom_date:
if fields.Date.from_string(rec.custom_date_from) - fields.Date.from_string(today) == 7:
mail = self.env['mail.template'].browse([('half_day_leave.leave_email_template')])
mail.send()
else:
if fields.Date.from_string(rec.custom_date_from) - fields.Date.from_string(today) == 1:
mail = self.env['mail.template'].browse([('half_day_leave.leave_request_email_template')])
mail.send()
Thanks