I am trying to create an automated action. After a certain time, the system will send an automatic email. But it is showing following error:
raise UserError(_("Failed to render template %r using values %r")% (template, variables))
on py file the code is below:
def follow_up_date_scheduler_queue(self):
today = fields.Date.context_today(self)
tomorrow = fields.Date.from_string(today) + timedelta(days=1)
identities = self.search([('follow_date', '=', tomorrow)])
# Find the e-mail template
template = self.env.ref('identity_check.email_template_for_identity_followup')
for identity in identities:
self.env['mail.template'].browse(template.id).send_mail(identity.id, force_send=True)
# return mail_id
return
On XML file the email template code is below:
<!--Email template-->
<record id="email_template_for_identity_followup" model="mail.template">
<field name="name">Send Identity Followup email</field>
<field name="email_from">${object.user_id.email}</field>
<field name="subject">Followup for ${object.name}</field>
<field name="email_to">${object.user_id.email}</field>
<field name="model_id" ref="base.model_res_partner"/>
<field name="auto_delete" eval="True"/>
<field name="lang">${object.lang}</field>
<field name="body_html"><![CDATA[
"""
Write here a body of email using HTML tag.....
"""
]]></field>
</record>
In xml model_id line is:
<field name="model_id" ref="identity_check.model_partner_identity"/>