Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odgovori
12690 Prikazi

Dear Sir/Madam,
How could I automatically send email when I submited a form.
Thank You

Avatar
Opusti
Best Answer

You need to have a python code that will generate the mail and send. You can place the below code (and modify it to fit your needs) in the model for which you want to send email, and than call the method send_mail("name of the temlate") from the code that handles your form submission, or I prefer to have a workflow associated with the model and send mail from the actions in the workflow.

    def send_mail(self, cr, uid, ids, context=None, template=""):
       for object in self.browse(cr, uid, ids, context=context):
            # Check if the parnter has "opt_out" for the mail
            if (not
object.partner_id.opt_out):
                template_id =
self.pool.get('email.template').search(cr, uid, [("name","=",template)])
                if template_id:
                    mail_message = self.pool.get('email.template').send_mail(cr,uid,template_id[0],object.id)

 

Avatar
Opusti
Avtor

PLEASE GIVE ME ONE COMPLETE EXAPMPLE

Can you explain? The code above is a compete example of sending email, all you need to do is to add the code to your model and call the self.send_mail from the place you need.

Best Answer

hi aneesh,

you can sent the email automatically by using server actions.

You see the following link for using the automated email:

http://stackoverflow.com/questions/23908437/how-to-create-program-for-sending-mail-automatically-from-openerp-using-python

https://www.odoo.com/forum/help-1/question/create-a-module-for-automatic-send-email-when-customer-has-been-created-59924

Avatar
Opusti