Skip to Content
Menu
This question has been flagged
2 Replies
8135 Views

Hi Guys.

I developed a module in odoo 12. And now i am need that  module send a email to user when he finish you action. But i dont know how to make my module send that email automatically. Some of you guys can help me with that? 

Thanks a lot.



Avatar
Discard
Best Answer

Hi,

Either you can use the automated action to send the email or you can send the email using the python code. 


For sending the email is using the automated action what you have to do is that, activate the developer mode and navigate to Settings -> Technical -> Automation -> Automated Actions, here you can create a record for sending email for the purpose. Make sure that the module with the technical name base_automation is installed in the database, if not you cannot see the specified menu. Here create a new record, in the Action To Do field choose the Send Email option. You can create this from the user interface or by the code.


For sending the email from the code, either you can send the email using a template or without the template. For sending the email using the email template see this blog: Finding and sending e-mail templates in Odoo


Thanks

Avatar
Discard
Best Answer

to send an email write the following code in method you are calling

def method(self):

mail_obj = self.env['mail.mail']​

body_html = "<p>message</p>"

mail = mail_obj.create({
'body_html':body_html,
'email_to':(user email field),
})
mail.send()

Avatar
Discard
Related Posts Replies Views Activity
2
May 16
9644
0
Nov 24
48
2
Feb 23
1162
1
May 15
5871
1
Mar 15
4590