Odoo Help


How to attach a pdf and send mail on click of button in openerp 7.0

on 11/21/13, 11:26 PM 4,355 views

I need to add pdf as an attachment and send mail to partner on click of customised button in form openerp 7.0 , how to achieve this scenario

Where you want this?

on 11/22/13, 12:19 AM

in sale_order i have created a button called approve contract, on click of this button i should attach the pdf for the template and send the mail to the partner

on 11/22/13, 12:40 AM
Prajul P T
On 11/22/13, 1:04 AM

In OpenERP 7.0 Quotation, there is a button called "Send By Email" which when clicked opens the related template of sale order. From here you can send the Quotation to the partner. We can also specify the report to be attached with this mail in the template ie; in Settings > Email > Email Template, in tab "Advanced", there is a field called "Optional report to print and attach". You can specify the report to attach with the mail in this field. If you want to add the functionality to send the mail automatically from your button action, you can call function send_mail in email.template model which sends the mail for the record using the template specified as arguments.

self.pool.get('email.template').send_mail(cr, uid, template_id, record_id, force_send=True, context=context)

where template_id is the id of the template to use to send the mail, record_id is the id of the record in your case sale order id, force_send which when set true will send the mail instantaneously without queuing the mail in the email queue manager.

Thanks for your reply, but in my case i am opening and wizard for this operation, onclick of button directly the template and pdf has to be sent for the partner, how this can be achieved

on 11/22/13, 1:55 AM

So the button to send the mail is in your wizard??

Zesty Beanz Technologies, Prajul P T
on 11/22/13, 1:57 AM

no the button is similar to send_mail button in sale_order, i have created as approve contract ,onclick of this button then a am able to send the template automatically but for that template i need to atach the report for this template

on 11/22/13, 2:01 AM

In template in location Settings > Email > Templates, there is a tab called "Advanced". In this tab there is a field called "Optional report to print and attach". You can specify the report you want to attach i this field.

Zesty Beanz Technologies, Prajul P T
on 11/22/13, 2:06 AM

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

0 follower(s)


Asked: 11/21/13, 11:26 PM
Seen: 4355 times
Last updated: 3/16/15, 8:10 AM