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.
I am working on timesheet module odoo of some report generation,
In Timesheet Activity Tree view once we select any record More option will display, in More option i had put one button that call one wizard. In that wizard i had put two button one is generating report(RML Report) (list of all timesheet line based on Analytical Account).
and other button send a mail to a client of Analytical Account , Now here i get stuck that how can i automatically attach a pdf report which i had generated or it automatically generate new pdf and attach automatically in email.
in function you call by pushing your button, when you call method send_mail of model email_template ((module email_template), add in context all informations you need to build your pdf and id of the email in a list with key 'add_pdf': [email_id, 'file_name.pdf', ....]. for function parameter 'force_send' set value True, then the method send of mail_mail model module mail) will be called by inheriting the context.
In this function, variable attachments contains files to send with code:
# load attachment binary data with a separate read(), as prefetching all
# `datas` (binary field) could bloat the browse cache, triggerring
# soft/hard mem limits with temporary data.
attachment_ids = [a.id for a in mail.attachment_ids]
attachments = [(a['datas_fname'], base64.b64decode(a['datas']))
for a in ir_attachment.read(cr, SUPERUSER_ID, attachment_ids,
you should override after this code in your module by overriding method send:
+ test if key 'add_pdf' is in the context
+ if yes test email_id of the key 'add_pdf' with current email_id of function send of the for loop.
+ if yes, call your function which genarates your pdf using informations you have in key 'add_pdf' and had tuple ('file_name.pdf', file) to the variable attachments list
I had made one email template for sending mail, and initially my pdf is not store in attachment, i want to add dynamically.
Means once i click a button called send email , one function call that internally call my email template and send msg to client, but in that mail i want to also attach my pdf which automatically( its call generate pff method and attach in email)
First you need to create a template for your email ,settings->email->template-> create -> Name-(User defined), Applies to- description to model, model- model for creating email, and you can give acces rights, on the content tab you need create the template. In email configuration you need to configure your email address for sender and receiver. And in advanced setting you have an option that you can add a attachment automatically by giving the optional report to print or attach and save the template.
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: 3/20/15, 2:06 PM|
|Seen: 3079 times|
|Last updated: 9/16/15, 7:45 AM|