This question has been flagged
1 Reply
8491 Views

Hello,

I've got a couple of questions related to attaching files in emails using templates:

1. When sending Sale Order by eMail, I am looking for a way to attach to the email more than one files already stored in ir.attachment linked to the SO by a Many2many relation. I see that templates allow me to attach only one file to the mail view by using options in Advance Settings Tab-->Optional report to print and attach. Does anybody knows if it is possible to configure templates to do it, or has an idea on the way I should proceed?

2. Is it possible to instruct templates to attach other kind of files than pdfs or html (i.e. png or xml files)?

Thanks in advance. I appreciate your help.

Avatar
Discard
Best Answer

The template it's not restricting you from attach any kind of files, you should be able to do it, but you need to pass more that one attachment to the mail message wizard using the field attachment_ids and the wizard will open with more that one attachment. The email.template model also has the field attachment_ids. You need to intercept the mail compose wizard to add the new attachments, because the sale order report is generated by default using the report template in the template rendering. For that you need to create your version of the Mail Compose Wizard to change the method get_mail_values to add the needed attachments to the mail values return dict so the compose wizard could create the mail.mail with the attachments and convert each of them before send it. Use that new wizard model in the method action_quotation_send of the sale.order as the res_model of the return dict and you will be ok

Avatar
Discard
Author

Thank you for your response Axel. I wil try your suggestion and get back to comment what I will find. Javier

Author

Thanks a lot for your guidance Axel. Now everything is working properly.

That's worth an accept on the answer then

Hey Axel,

I know this is an old topic but is this also possible on the odoo.com plattform? I'm currently on V14 and need to this exact thing. I have multiple different attachments on every offer and want to send it with the email from the wizard.

greetings Jakob

@Jakob Bader I think the same should work with minor changes but the idea in the answer remains the same in new versions

Hey Axel,

could you point me in the right direction? Is this even possible in the odoo online version. I don't have access to the code only via studio and xml.

No, sorry, I don't think it could be done in Odoo online

Hello @Axel Mendoza, i know this is also late, but it sounds like the answer you posted is just what I need, the problem is, i dont know how to do it. Can you show me with a code example, how to add an attachement to the email composer with the python code? Your help is greatly appreciated!