# Send an email automatically passed some days after processing the dunning

**URL:** https://discuss.tryton.org/t/send-an-email-automatically-passed-some-days-after-processing-the-dunning/4591
**Category:** User
**Created:** [September 5, 2021, 4:29am UTC](https://discuss.tryton.org/t/send-an-email-automatically-passed-some-days-after-processing-the-dunning/4591 "2021-09-05T04:29:58Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mimo\_Alva](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/m/a698b9/32.png) [@mimo\_Alva](https://discuss.tryton.org/u/mimo_Alva)
#### Post date: [September 5, 2021, 4:29am UTC](https://discuss.tryton.org/t/send-an-email-automatically-passed-some-days-after-processing-the-dunning/4591/1 "2021-09-05T04:29:58Z")

</div>

Hello, I wanted to propose a thing that I do not know if it is possible to do it. The idea is as follows:  
After creating a dunning and after define a due date, the first level of dunning should be reached when the first 10 days after the due date have passed, the first payment reminder (the email ) should be sent. Then the 2nd dunning level should be reached after 20 days have passed, and the 3rd when 30 days have passed . When this 3 levels are done the system should change status from “Waiting” to “Final/Processed”.  
1st level-after 10 days  
2nd level-after 20 days  
3 rd level-after 30 days  
Here I want to know, what are the fields I should fill out and what I I should put on the field ‘’ overdue ‘’ to make it respect automatically send an email after passing 10 days after processing each level?  
Ps:for now everything is going good with the module dunning but it sends an email just everytime I process the dunning, and me I want that this process sent an email after passing 10 days at the first level , then the second level after 20 days,… My problem here is how I should fill out the fields and what are the fields I should fill out to do this thing and sending an email after some days I define them ? .

---

<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 5, 2021, 7:12am UTC](https://discuss.tryton.org/t/send-an-email-automatically-passed-some-days-after-processing-the-dunning/4591/2 "2021-09-05T07:12:11Z")

</div>

So basically you want to be able to send a reminder for the reminder.  
I think it should be possible to use the `notification_email` module with a trigger based on time. The condition could be `Eval('state') == 'waiting' & (Eval('since') - Eval('current_date')).days >= 10` and with `minimum_time_delay` set to maybe 10 days.  
So the only missing part is to store on a field `since` when the dunning was set to waiting. And I think such field would be useful in many cases so it could be added in standard.

---

<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 5, 2021, 8:38am UTC](https://discuss.tryton.org/t/send-an-email-automatically-passed-some-days-after-processing-the-dunning/4591/3 "2021-09-05T08:38:08Z")

</div>

For the record I filled [Add date and age to dunning (#10722) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue10722)

---

<div class="post-metadata">

### Author: ![mimo\_Alva](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/m/a698b9/32.png) [@mimo\_Alva](https://discuss.tryton.org/u/mimo_Alva)
#### Post date: [September 5, 2021, 5:54pm UTC](https://discuss.tryton.org/t/send-an-email-automatically-passed-some-days-after-processing-the-dunning/4591/4 "2021-09-05T17:54:32Z")

</div>

Good morning M@ced

> [@ced](#):
>
> The condition could be `Eval('state') == 'waiting' & (Eval('since') - Eval('current_date')).days >= 10` and with `minimum_time_delay` set to maybe 10 days.

1/IHere i would to know where i should add this block of code and those fields should i add them on the module “notification\_email” after activate it or just put them on the model “'account.dunning.level” ?  
2/ if we will use email\_notification module, so what’s the function of the Levels :SO herei have a question may make things for me more clear, i have thought from the beginning that `Levels help us to define the date when the email should be sent by using the field "overdue" and by processing the dunning, it passes to another level?`;, am i wrong , please can u tell me clearly what’s the function of this Level in the dunning module!?  
3/About `[Issue 10722: Add date and age to dunning - Tryton issue tracker](https://bugs.tryton.org/issue10722)`  
i have tested that by doing those steps:

I have trying create a payment term (see the image below please)

 ![image](https://discuss-cdn.tryton.org/uploads/default/original/2X/7/75b3ad44f28d8b4cc0a83916185221110edb95c2.png)

then i created a dunning (As shown in the following picture ):

 ![image](https://discuss-cdn.tryton.org/uploads/default/original/2X/0/058f80a0f230f775d9c6b560f842191d929ef866.png)

in the field` Invoice Payment` , i filled it out as shown in the following picture :

 ![image](https://discuss-cdn.tryton.org/uploads/default/original/2X/e/ec9242862d7926da7713c4c390abe3f0b7fb5c0a.png)

in the `Procedure` field , i have define the first Level (email should be passed after 10bdays) as shown in the following picture :

 ![image](https://discuss-cdn.tryton.org/uploads/default/original/2X/a/ad10e8451c27c58684d018878dceae6691dd98e4.png)

and finally when i process the dunning still sent me the email once i process the dunning and not after 10 days

also the age give me “00:00” and the date is the day of today(as shown in the following image) !!?

 ![image](https://discuss-cdn.tryton.org/uploads/default/original/2X/f/fc8ecf136826c933e3cee8406b3cca93276f46c3.png)

i do no what’s wrong and what i should modify to reach my goal to send the email after 10 days and not of the moment when i try to process dunning!
