# Email notification

**URL:** https://discuss.tryton.org/t/email-notification/71
**Category:** Ideas
**Created:** [March 4, 2016, 6:41pm UTC](https://discuss.tryton.org/t/email-notification/71 "2016-03-04T18:41:54Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [March 4, 2016, 6:41pm UTC](https://discuss.tryton.org/t/email-notification/71/1 "2016-03-04T18:41:54Z")

</div>

## Description:

Tryton is able to trigger action based on record change. The idea is to have a module that provides a way to the user to define email template for a kind record that could be used by a triggered action to send email to a list of users. For example, it should be possible to send an email to the customer when its sale order is validated.

## Skills:

Knowledge in Python and Template engine like Genshi.

## Difficulty level:

Intermediate

## Potential mentors:

- @ced
- @kstenger
- @nicoe

## Implementation

> **[RFC: Email Notification (#5835) · Issues · Tryton / Tryton · GitLab](https://foss.heptapod.net/tryton/tryton/-/issues/5835)**
>
> Following: https://discuss.tryton.org/t/email-notification/71/12

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [March 4, 2016, 11:12pm UTC](https://discuss.tryton.org/t/email-notification/71/2 "2016-03-04T23:12:02Z")

</div>

We have some modules that implement such functionality:

[https://bitbucket.org/nantic/trytond-electronic\_mail](https://bitbucket.org/nantic/trytond-electronic_mail)  
[https://bitbucket.org/nantic/trytond-electronic\_mail\_template](https://bitbucket.org/nantic/trytond-electronic_mail_template)  
[https://bitbucket.org/nantic/trytond-electronic\_mail\_wizard](https://bitbucket.org/nantic/trytond-electronic_mail_wizard)

So maybe they can be taked in account as a base.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [March 4, 2016, 11:36pm UTC](https://discuss.tryton.org/t/email-notification/71/3 "2016-03-04T23:36:07Z")

</div>

We should not create mailbox nor queue. Tryton is not the right tool for such things.  
Indeed the development should be based on the future [two-phase commit](https://bugs.tryton.org/issue3553).  
Also the templating should re-use as much as possible the Report infrastructure.

---

<div class="post-metadata">

### Author: ![vincent](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/vincent/32/29_2.png) [@vincent](https://discuss.tryton.org/u/vincent)
#### Post date: [March 9, 2016, 9:34am UTC](https://discuss.tryton.org/t/email-notification/71/5 "2016-03-09T09:34:42Z")

</div>

I would love to be involved in this.

---

<div class="post-metadata">

### Author: ![vincent](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/vincent/32/29_2.png) [@vincent](https://discuss.tryton.org/u/vincent)
#### Post date: [March 9, 2016, 9:50am UTC](https://discuss.tryton.org/t/email-notification/71/6 "2016-03-09T09:50:00Z")

</div>

Yes, this idea is about email notifications or alerts, not the functionality of a user sending an email from Tryton like they would from an email client.

This is about setting up a workflow for email notifications with rules. Perhaps we should be able to trigger an email if a field is changed to a particular value? Perhaps we could have a more complicated formula with many fields.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [March 9, 2016, 10:42am UTC](https://discuss.tryton.org/t/email-notification/71/7 "2016-03-09T10:42:02Z")

</div>

> [@vincent](#):
>
> Perhaps we should be able to trigger an email if a field is changed to a particular value? Perhaps we could have a more complicated formula with many fields.

This is already managed in a very flexible way by the `ir.trigger`.

---

<div class="post-metadata">

### Author: ![jeromecc](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/jeromecc/32/81_2.png) [@jeromecc](https://discuss.tryton.org/u/jeromecc)
#### Post date: [June 22, 2016, 12:50am UTC](https://discuss.tryton.org/t/email-notification/71/8 "2016-06-22T00:50:46Z")

</div>

Hello!

Could you explain in a few words the mechanism of ir.trigger? I want to know if Tryton has some kind of observer pattern mechanism like signals and slots in Qt. I am looking for an open source server side component for an healthcare software project (freemedforms) with this feature to automate notifications based on (clinical) rules. I guess GNU Health could benefit from such a feature too.

Thanks.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [June 22, 2016, 7:47am UTC](https://discuss.tryton.org/t/email-notification/71/9 "2016-06-22T07:47:36Z")

</div>

The ir trigger allows to define a method that will be called on the following events:

- Record Creation
- Record Modification
- Record Deletion

You can also specify a condition on the trigger to limit the affected records.

This allow, for example, to call a trigger when a sale order is confirmed.  
So with the email notification feature we will allow to send an email when the sale order is confirmed.

You have a lot of examples in the tests methods:  
[  
http://hg.tryton.org/trytond/file/tip/trytond/tests/test\_trigger.py#l73](http://hg.tryton.org/trytond/file/tip/trytond/tests/test_trigger.py#l73)

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [June 22, 2016, 7:49am UTC](https://discuss.tryton.org/t/email-notification/71/10 "2016-06-22T07:49:34Z")

</div>

Instead of answering here (which will be bury deeper in discourse), you should add it to the documentation.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [July 11, 2016, 9:09am UTC](https://discuss.tryton.org/t/email-notification/71/11 "2016-07-11T09:09:31Z")

</div>

> [@ced](#):
>
> Instead of answering here (which will be bury deeper in discourse), you should add it to the documentation.

Just for the follow-up, i created [Add docs about ir.trigger (#5699) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue5699) to add docs about ir.trigger

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [August 25, 2016, 11:59am UTC](https://discuss.tryton.org/t/email-notification/71/12 "2016-08-25T11:59:45Z")

</div>

I’m wondering if we should include it as trytond base instead of using a new module.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [August 26, 2016, 8:39am UTC](https://discuss.tryton.org/t/email-notification/71/13 "2016-08-26T08:39:34Z")

</div>

If it is possible to just make a module, it is always better.

---

<div class="post-metadata">

### Author: ![oscar](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/oscar/32/1919_2.png) [@oscar](https://discuss.tryton.org/u/oscar)
#### Post date: [September 7, 2016, 6:57pm UTC](https://discuss.tryton.org/t/email-notification/71/14 "2016-09-07T18:57:58Z")

</div>

I am wondering if it is possible has two options for to trigger the send email, by ir.trigger and by ir.cron, for example we want to schedule with CRON option send mail to all customers when a invoice is past due bill, and this CRON is set a specific hour or day of week.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [September 8, 2016, 7:34am UTC](https://discuss.tryton.org/t/email-notification/71/15 "2016-09-08T07:34:50Z")

</div>

Triggers can be based also on time, so for me this will be supported.

> [@oscar](#):
>
> send mail to all customers when a invoice is past due bill

A little bit of topic but this is managed by dunning module.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [December 13, 2017, 9:17am UTC](https://discuss.tryton.org/t/email-notification/71/16 "2017-12-13T09:17:54Z")

</div>


