Date comparison using Pyson

At present, in pyson, only the integer and float values can be compared. If we write a pyson statement as -

'invisible': Or(~Eval('state').in_(['disclose', 'signed']), (Eval('date_signed_ratee') <= Date(delta_days=15)))

Following error is raised-

Traceback (most recent call last):
  File "./bin/trytond-admin", line 21, in <module>
  File "/path/trytond/", line 54, in run
  File "/path/trytond/", line 160, in init
    lang=lang, activatedeps=activatedeps)
  File "/path/trytond/modules/", line 418, in load_modules
  File "/path/trytond/modules/", line 388, in _load_modules
    load_module_graph(graph, pool, update, lang)
  File "/path/trytond/modules/", line 201, in load_module_graph
  File "/path/trytond/", line 234, in setup
  File "/path/lib/python3.6/site-packages/trytond_apar-5.0.0-py3.6.egg/trytond/modules/apar/", line 205, in __setup__
    ['disclose', 'signed']), (Eval('date_signed_ratee') <= Date(delta_days=15))),
  File "/path/trytond/", line 73, in __le__
    return Less(self, other, True)
  File "/path/trytond/", line 300, in __init__
    'statement must be an integer or a float'
AssertionError: statement must be an integer or a float

IMO, the init method of ‘Greater’ class in pyson should be able to compare the dates as well or am I doing something wrong here.

It is a feature request: Issue 4879: Suport Date, DateTime and Decimal fields in Greater/Less Pyson statement - Tryton issue tracker

Thanks @ced. Let me work on it and then I will submit my changes on it.

1 Like