Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Follow is my code to send email:
domain = [('name','like','EAR Activation Request')]
template = self.env['email.template'].search(domain, limit=1)
template = template
My template is getting all the data correctly from model. However, I need to pass a dynamic data to the template before sending email. Be it email_to or ip_address. Can someone guide me how can I pass these two variables on runtime in my python code before send_mail function so the template pick them?
Hi Alex below i am posting the code for new and simple way for doing this task
please use self.env.ref instead of self.env['email.template'].search(domain, limit=1)
mytemplate_obj = self.env.ref('my_module.my_mail_template', False)
here the mytemplate_obj is the object of email.template , it's mean it's a active record .
Now You can change/set the field value (email_from,subject,email_to)of this object simply and call the send_mail.
Hope this may help you.
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
|Asked: 4/20/16, 7:38 AM|
|Seen: 659 times|
|Last updated: 4/20/16, 12:29 PM|