Send Email in Odoo From Code
To send an email in Odoo first of all we need create email template. We can create this email template using following two ways.
- By using Email Template Menu Interface
- By using xml (code)
By using Odoo interface firstly we create a email template by clicking on “Create” button and fill the form.
Read More: How to display confirmation display box / message box on button click
- Create new xml file in your module
- Copy below code and past in your newly created xml file
- Register your newly created xml file in openerp.py
Create Email Template
Now
its time to write button method/function to send an email. Follow
these steps to create a button and its event/function.
Read More: How to Open a Wizard on Button Click in Odoo
<button string="Send Email" type="object" name="btn_send_email " confirm="Are you sure you want to Send email to students?" />
8 Comments
Hello
ReplyDeleteso how to Handle button method in models.py file?
now it return this error
AttributeError: 'res.letter' object has no attribute 'btn_send_email
Hey,
ReplyDeleteYou must create button code "btn_send_email" in XML of your "res.letter" model.
can we write btn_send_email instead of proposal_title_approved function?
ReplyDeleteIf I didn't have an attribute name btn_send_email.
and It didn't work yet. How it will work please let me know.
yes, you can write any meaningful name...
DeleteGood mornning. Please I get this error when using the above xml file. Can some one help me solve this ?
ReplyDeleteParseError: "External ID not found in the system: sunu__stock.model_postgraduate_thesis"
sunu__stock.model_postgraduate_thesis
DeleteIn above line you just need to change your model name like " sunu__stock.model_your_model_goes_here"
Hello I'm stuck on configuring mail too with v11, can someone assist me ?
ReplyDeleteIt can send real mail? Use as recipient email definite in @api? Thanks
ReplyDelete