I had some discussion with @JCavallo where he told me that they’re using a lot of function fields but only to access them in the code but never to present them in the interface.
While this is not exactly a big issue to create the field in the usual way it can become a bit cumbersome.
So I had this idea: why not creating a kind of decorator as the
@property decorator of python.
It could result in something like:
class Model: __name__ = 'whatever' @tryton_property @classmethod def my_computation(cls, models, name): pass @my_computation.setter @classmethod def my_computation(cls, models, name, value): pass @my_computation.searcher @classmethod def my_computation(cls, name, clause): pass
It would be purely syntactic sugar in order to fill the
cls._fields dict. Of course it should work also on function fields where the getter is an instance method. The
tryton_property decorator should support all the parameters
fields.Function supports. The main problem I see is with the modularity as I am not sure how it could work yet.
We might want to forbid access from the outside to those fields but I am not sure that it would be a problem anyway.