Configure the notification email

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.

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).

Hi i was put it :

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

----> but it doesn’t work

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

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

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


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

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!!

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)

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

1 Like

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

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)

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.

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 ?]

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:

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!?

Then there is something wrong.

It seems that timedelta are not supported in PYSON expression (PYSON does not encode timedelta (#10727) · Issues · Tryton / Tryton · GitLab).

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))

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 .

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".