Skip to Content
Menu
This question has been flagged
2 Replies
7473 Views
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>

Avatar
Discard
Author

In xml model_id line is:

<field name="model_id" ref="identity_check.model_partner_identity"/>

Author Best Answer

The problem was with noupdate="1" . While I was upgrading the module the record wasn't updating. And my object didin't has lang attribute, so I used

${object.env.user.lang}
Avatar
Discard
Related Posts Replies Views Activity
0
Dec 24
12
0
Nov 24
6
0
Nov 24
53
0
Nov 24
265
0
Oct 24
124