Odoo Help

-1

Error when sending email with template in Odoo 9

By
Jorge
on 30/10/17 05:17 145 views

Hello guys , I have the following code:

                mail_pool = self.pool['mail.mail']

                data_pool = self.pool['ir.model.data']

                template_xmlid = 'holidays_email_template_a_manager_aprobar'

                template_pool = self.pool.get('mail.template')

                template_id = data_pool.get_object_reference(cr, uid, 'hr_holidays', template_xmlid)

                for attendee in self.browse(cr, uid, ids, context=context):

                    template_pool.send_mail(cr, uid, template_id, attendee.department_id.manager_id.user_id.email,

context=context)


But when I try to send email I have this error:

ValueError: "Expected singleton: mail.template(u'mail.template', 24)" while evaluating
u'holidays_confirm()'

Could someone help me? Thank you! 

Please use a meaningful title, your error message tells exactly what is going wrong.

Ermin Trevisan
on 30/10/17 06:12
-1
Jorge
On 30/10/17 06:14

I find a little solution adding [1] in template_id = data_pool.get_object_reference(cr, uid, 'hr_holidays', template_xmlid)[1]

But now I'm having this error:

Failed to render template <Template memory:7f9184726d90> using values {'format_tz': <function <lambda> at 0x7f9199b3d8c0>, 'ctx': {}, 'user': res.users(6,), 'object': None}

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 30/10/17 05:17
Seen: 145 times
Last updated: 30/10/17 11:16