Odoo Help


How to set "email_to" in email template dynamically

Shaffaf R S
on 2/13/18, 11:15 AM 462 views


I want to dynamically set email_to field in the email template. If I press the send email button the email should only send to the corresponding sales person's and division manager's mail id ie, partner specified in the invoice line. Please do help.  

Hello Shaffaf R S,

In your custom send mail method add code like as below,

template_id = self.env['ir.model.data'].get_object_reference('module_name', 'template_name')

template_rec = self.env['mail.template'].browse(template_id[1])

template_rec.write({'email_to': 'xyz@xyz.com'})

template_rec.send_mail(emp, force_send = True)


Dipak Shah
on 2/13/18, 12:55 PM

thank you Dipak Shah for your response, but in this case i can't hard-code a particular email address because there are multiple lines and i need to send mail to each sales person of the partner.

Shaffaf R S
on 2/13/18, 1:15 PM

Yeah so instead of hard coded email address you can use with ur emails .if it's multiple emails you can add that all into a single list and write email to Field according once only !!


Dipak Shah
on 2/13/18, 2:41 PM

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.


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)


Asked: 2/13/18, 11:15 AM
Seen: 462 times
Last updated: 2/13/18, 12:00 PM