Mails Dynamic Attachments

by
Odoo
v 12.0 Third Party 48
Download for v 12.0 Deploy on Odoo.sh
Availability
Odoo Online
Odoo.sh
On Premise
Lines of code 275
Technical Name odoo_mail_attachments
LicenseAGPL-3
Websitehttps://www.alliantum.com
Versions 13.0 14.0 12.0
You bought this module and need support? Click here!
Alliantum

Mails Dynamic Attachments

Beta License: AGPL-3 Alliantum/odoo_mail_attachments

By default, Odoo provides us with options to attach certain documents to our email templates. They can be both, static files, like images, pdf, text files… and also dynamic reports that are generated depending on the current record, like for example a SO pdf to be sent to your customer.

But what happens when you would like to add more dynamic attachments, like for example, not just the SO document, but also the Delivery Slips of the related shipping for that SO? And even, do this just under certain circumstances! That’s the point where this module become handy.

With this module you can start creating rules for objects like Sales Order, Invoices, Purchases or another, that will decide which pdf document will be attached to the emails sent from the context actions of that object. The power of this module is that those pdf Documents can be generated dynamically from related objects to the current one.

The rules will allow you to define under which circumstances, depending on the fields of the current object you want the attachments to be generated, filter the related objects, attach static files based on rules, and attach static files based on languages.

Table of contents

Configuration

  1. In order to add dynamically attachment to your emails. You must go to Settings / General Settings and scroll down to the bottom. A new section Dynamic Mail Attachments will have appeared there, then click on Manage button to launch the wizard and start creating rules.
Alliantum
  1. Start adding attachments is very easy, just click Add a line, then select the Model on which the current line will apply (for example, when sending an email from a Sale Order), and also decide the pdf Report to be used.
Alliantum
  1. Now it’s very important to pay attention to the Path to Report Model field. Here you need to enter the path to follow starting from the Trigger Model to the records that will be used by the Report. For doing this you can use dot notation when needed (see example below), in picture picture, it’s just ``picking_ids``. In case you don’t have access to the code used for create the objects, you can activate the developer mode in Odoo, and hover the fields to get the technical name of the field.

For example:

  • Your rule applies to Sale Order, then if you want to attach the Delivery Slip to a Sale Order, you simply have to enter ‘picking_ids’.
  • But, if your rule applies to Invoices for example, you will need maybe something like, ‘invoice_line_ids.sale_line_ids.order_id.picking_ids’. Notice here how the x2many fields are including here all the possible existing records.
Alliantum
  1. Filtering is also available to decide in which circumstances our rule line will take action. If you just need to attach certain file for a Sale Order, which Customer has some special value in a concrete field, let’s say, partner_id.is_premium, then you can use the button Add Filter to enter a domain that matches your needs. Something similar can be also done for the related object, in our examples the Delivery.
Alliantum
  1. Continuing with more extra options, we can for instance attache static files in a couple of ways, one for adding to your email attachments that were already loaded in Odoo, or to upload on the fly a new one that really suits you.
  2. And finally, there’s a powerful way of attaching files based on the language of one of the related records of the correct object (images that includes text, Terms and Conditions, or any other kind of document). You can think of it like, again, in a SO, when we need to attach some file in the language of our customer. Let’s say, that in out Sales Order, our Customer has set Language to French, in such a case, our configuration line will look like this:
Alliantum

Usage

Once everything is configured, the only thing you need to do is go ahead to one of the objects that allow sending emails, and try sending one of them, for one record that matched your rules criteria. Then in the chatter, you should find the attachments that applies in that case.

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

Credits

Authors

  • Alliantum

Other credits

The development of this module has been financially supported by:

  • Alliantum (https://www.alliantum.com)

Maintainers

This module is maintained by Alliantum.

Alliantum

Alliantum, is a company whose mission is to support the widespread use of Odoo by others companies, and collaborate in the development of new Odoo features.

This module is part of the Alliantum/odoo_public_modules project on GitHub.

You are welcome to contribute. To learn how please visit https://github.com/Alliantum/odoo_public_modules.

Please log in to comment on this module

  • The author can leave a single reply to each comment.
  • This section is meant to ask simple questions or leave a rating. Every report of a problem experienced while using the module should be addressed to the author directly (refer to the following point).
  • If you want to start a discussion with the author, please use the developer contact information. They can usually be found in the description.
Please choose a rating from 1 to 5 for this module.