# Configure the notification email

**URL:** https://discuss.tryton.org/t/configure-the-notification-email/4595
**Category:** User
**Tags:** notification
**Created:** [September 6, 2021, 7:03am UTC](https://discuss.tryton.org/t/configure-the-notification-email/4595 "2021-09-06T07:03:20Z")
**Posts on this page:** 11
**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 6, 2021, 7:03am UTC](https://discuss.tryton.org/t/configure-the-notification-email/4595/1 "2021-09-06T07:03:20Z")

</div>

HI;  
After activating the module"notification\_email" , i was about going to the administration and create a trigger “time”, about the condition block ;

when i put it `Equal(Get(Eval('state') == 'waiting' & (Eval('date.today()') - Eval('date.today()')).days >= 10))` but , it dosn’t work.

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

---

<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 6, 2021, 3:49pm UTC](https://discuss.tryton.org/t/configure-the-notification-email/4595/2 "2021-09-06T15:49:03Z")

</div>

> [@mimo\_Alva](#):
>
> when i put it `Equal(Get(Eval('state') == 'waiting' & (Eval('date.today()') - Eval('date.today()')).days >= 10))` but , it dosn’t work.

indeed the condition can not have operation like the subtraction. So you need to have a field on the model that does the computation (like `age`).

---

<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 6, 2021, 4:34pm UTC](https://discuss.tryton.org/t/configure-the-notification-email/4595/3 "2021-09-06T16:34:16Z")

</div>

> [@mimo\_Alva](#):
>
> (‘state’) == ‘waiting’ &

Hi i was put it :

` Equal(Get(Eval("self", {}), ('state') == 'waiting' & age >= 10)))`

----\> but it doesn’t work

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

so as a try **`i was about fix in the triggers Model(under administration) that the e-mail should be sent after two hours and not after 10 days `**

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

**`then i have create a notification_email record (menu under administration)`**

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

`and finally i was about creating a dunning and a procedure composed by 3 levels, each level after two hours.`

 ![image](https://discuss-cdn.tryton.org/uploads/default/original/2X/2/2e94b633c6be90c111c11da60f0ff5654062a0c8.png)  
then` i process the dunning` and as habitual am waiting that the email should be sent **but nothing happen** , it sends me email just at the time when i do “process dunning” and not after two hours like i have already fixed it.

i think i should see “Notification Emails” after activating the module"notification\_email" as an action in the dunning window, but unfortunately i just see “Email archives”, “Email logs” ? is this the problem or should i do another step!  
–help please–thanks again for replying

---

<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 7, 2021, 3:42pm UTC](https://discuss.tryton.org/t/configure-the-notification-email/4595/4 "2021-09-07T15:42:41Z")

</div>

Hi again M.@ced ;

Today i have known that i should use the “age” to do what i want may be,

So i have try that using “age” attribute and it doesn’t give me any error: `Equal(Get(Eval("self", {}), "age == 10", "state"), "waiting")`  
as a verifying did u see that it can be workfull this pyson statement or not , if yes

i would to know to complete my configuration of the trigger about the field “model” and in the notification email should i choice them “account.dunning” or “account.dunning.level” or it doesn’t not matter the model here!!

---

<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 7, 2021, 3:46pm UTC](https://discuss.tryton.org/t/configure-the-notification-email/4595/5 "2021-09-07T15:46:53Z")

</div>

> [@mimo\_Alva](#):
>
> So i have try that using “age” attribute and it doesn’t give me any error: `Equal(Get(Eval("self", {}), "age == 10", "state"), "waiting")`

This is a weird statement because it tries to get the attribute “age == 10”.  
Indeed it should be something like:

`(Eval('self', {}).get('state') == 'waiting') & (Eval('self', {}).get('age', 0) > 10)`

> [@mimo\_Alva](#):
>
> i would to know to complete my configuration of the trigger about the field “model” and in the notification email should i choice them “account.dunning” or “account.dunning.level” or it doesn’t not matter the model here!!

It should be on `account.dunning` as it is the model that store the state and the age.

---

<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 7, 2021, 5:20pm UTC](https://discuss.tryton.org/t/configure-the-notification-email/4595/6 "2021-09-07T17:20:04Z")

</div>

> [@ced](#):
>
> (Eval(‘self’, {}).get(‘state’) == ‘waiting’) & (Eval(‘self’, {}).get(‘age’, 0) \> 10)

**`if (Eval("self", {}).get("state") == "waiting") & (Eval("self", {}).get("age", 0) > 10)`**

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

I have put it like that but also it doesn’t accept it , i guess may be it’s reliant to the version of tryton , (my version is 6.0)

---

<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 7, 2021, 5:36pm UTC](https://discuss.tryton.org/t/configure-the-notification-email/4595/7 "2021-09-07T17:36:56Z")

</div>

The web client does not support `&` and `==` syntax and if it `If`.  
So it should be:  
`And(Equal(Get(Eval('self', {}), 'state', ''), 'waiting'), Greater(Get(Eval('self', {}), 'age', 0), 10, True))`

PS: It is easier to write them on desktop client because the Python language allows to use some syntax-sugar.

---

<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 8, 2021, 8:28am UTC](https://discuss.tryton.org/t/configure-the-notification-email/4595/8 "2021-09-08T08:28:38Z")

</div>

Good morning M@ced:

i was about configured another trigger to send me email after **1 hour** to see the result quickly and don’t waiting those 10 days , so during the creating of the record of “notification email” i have choice two keyword (one **Action form** and the other **relate form** )[i do no if it’s okay to choice those two keywords when i choice the model ?]

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

```auto
about `Recipients:`(i have putted `Party(party)`)
about `Recipients Fallback User` (i have putted `Administrator`)

```

**`Minimum Delay: 01:00`**

**the condition** `And(Equal(Get(Eval('self', {}), 'state', ''), 'waiting'), Greater(Get(Eval('self', {}), 'age', 0), 1, True))`  
**After saving become---------\>**

`And(Equal(Get(Eval("self", {}), "state", ""), "waiting"))`

and finally i was about going to the menu `scheduler/Actions/method "run on time trigger "` to guarentee that the trigger work normally and the action will be passed and send me an email after one hour to remind me so i have put on `"nextcall" the next hour and ` when i click on “Run once” it gives me an error:

```auto
Traceback (most recent call last):
  File "/trytond/wsgi.py", line 117, in dispatch_request
    return endpoint(request, **request.view_args)
  File "/trytond/protocols/dispatcher.py", line 47, in rpc
    return methods.get(request.rpc_method, _dispatch)(
  File "/trytond/wsgi.py", line 84, in auth_required
    return wrapped(*args, **kwargs)
  File "/trytond/protocols/wrappers.py", line 156, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/trytond/protocols/dispatcher.py", line 181, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/trytond/model/descriptors.py", line 33, in newfunc
    return self.func(owner, *args, **kwargs)
  File "/trytond/model/modelview.py", line 774, in wrapper
    return func(cls, records, *args, **kwargs)
  File "/trytond/modules/company/ir.py", line 107, in run_once
    super(Cron, cls).run_once([cron])
  File "/trytond/model/descriptors.py", line 33, in newfunc
    return self.func(owner, *args, **kwargs)
  File "/trytond/model/modelview.py", line 774, in wrapper
    return func(cls, records, *args, **kwargs)
  File "/trytond/ir/cron.py", line 141, in run_once
    getattr(Model, method)()
  File "/trytond/ir/trigger.py", line 297, in trigger_time
    trigger.trigger_action(records)
  File "/trytond/ir/trigger.py", line 209, in trigger_action
    ids = [r.id for r in Model.browse(ids) if self.eval(r)]
  File "/trytond/ir/trigger.py", line 209, in <listcomp>
    ids = [r.id for r in Model.browse(ids) if self.eval(r)]
  File "/trytond/ir/trigger.py", line 188, in eval
    return bool(PYSONDecoder(env).decode(self.condition))
  File "/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
  File "/trytond/pyson.py", line 122, in _object_hook
    return klass.eval(dct, self.__context)
  File "/trytond/pyson.py", line 358, in eval
    dct = Greater._convert(dct)
  File "/trytond/pyson.py", line 351, in _convert
    dct[i] = float(stmt)
TypeError: float() argument must be a string or a number, not 'datetime.timedelta'

```

is their another step i forgot it, and this error can affect the notification email and will not be sent in the correct time!?

---

<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, 2021, 8:36am UTC](https://discuss.tryton.org/t/configure-the-notification-email/4595/9 "2021-09-08T08:36:00Z")

</div>

> [@mimo\_Alva](#):
>
> **the condition** `And(Equal(Get(Eval('self', {}), 'state', ''), 'waiting'), Greater(Get(Eval('self', {}), 'age', 0), 1, True))`  
> **After saving become---------\>**
> 
> `And(Equal(Get(Eval("self", {}), "state", ""), "waiting"))`

Then there is something wrong.

> [@mimo\_Alva](#):
>
> `TypeError: float() argument must be a string or a number, not 'datetime.timedelta'`

It seems that timedelta are not supported in PYSON expression ([PYSON does not encode timedelta (#10727) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue10727)).

So we should use the TimeDelta instead of interger like:

`And(Equal(Get(Eval('self', {}), 'state', ''), 'waiting'), Greater(Get(Eval('self', {}), 'age', TimeDelta()), TimeDelta(10), True))`

---

<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 8, 2021, 10:19am UTC](https://discuss.tryton.org/t/configure-the-notification-email/4595/10 "2021-09-08T10:19:06Z")

</div>

> [@ced](#):
>
> And(Equal(Get(Eval(‘self’, {}), ‘state’, ‘’), ‘waiting’), Greater(Get(Eval(‘self’, {}), ‘age’, TimeDelta()), TimeDelta(10), True))

thank you M. @ced but also it doesn’t work , i have trying some other tries but nothing go with it, i guess so `TimeDelta()` it’s not supported here .

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

---

<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 8, 2021, 1:17pm UTC](https://discuss.tryton.org/t/configure-the-notification-email/4595/11 "2021-09-08T13:17:41Z")

</div>

after some testing the timedelta type i guess is not supported also in comparison`"Equal`". after saving the trigger it seems okay and accept it but it gives me an error when i try to save the record of “notification email”

`#### Condition "{" __class__":"Equal","s1":{" __class__":"Get","v":{" __class__":"Eval","v":"self","d":{}},"k":"age","d":{" __class__":"TimeDelta","d":0,"s":0,"m":0}},"s2":{" __class__":"TimeDelta","d":10,"s":0,"m":0}}" is not a valid PYSON expression for trigger "test for 10 days".`
