Add Today and Now keywords to PYSON

Rational

Sometimes, we would like to be able to define a domain on an Act WIndow which relies on the current date / time to filter out some results. I am not aware of any possibility to implement this kind of behaviour in tryton.

Proposal

Add two new keywords to PYSON, in order to be able to declare domains such as :

  • [(‘date’, ‘<’, Today())]
  • [(‘create_date’, ‘<’, Now())]

Those keywords could optionnaly accept parameters to declare an offset, like :

  • [(‘date’, ‘>=’, Today(months=-2))]
  • [(‘created_date’, ‘>=’, Now(hours=-2))]

Constraints

I do not think that those keyword should be used to enforce constraints on fields, since they may become invalid just by waiting. Their intended use is primarily filtering in client side actions. Ideally, the server side implementation should be a no-op.

Also, it will be necessary to update the tab_domain behaviour client side to re-evaluate the domain when refreshing.

For me, it is useless because PYSON.Date and PYSON.DateTime uses by default today and now. See Date and DateTime.
About refreshing the domain, it is quite difficult because the screen only receives the evaluated domain. But it will be probably a good improvement.

Awesome !

I tinkered around a little, would it be ok to just set the action context and the non-evaluated domain in the tab_domain list , and decode it in get_tab_domain ?