Hello. I have need to campare a Date in pyson and I have modified pyson.py in trytond to support it, if someone wants to push upstream this is the patch.
--- pyson.py.old 2017-08-18 07:53:10.705049046 +0200 +++ pyson.py 2017-08-18 07:54:47.925945516 +0200 @@ -24,7 +24,13 @@ return reduced_type(func(*args, **kwargs)) return wrapper - +def date_to_float(statement1): + if isinstance(statement1, datetime.datetime): + statement1=(statement1-datetime.datetime(1970,1,1)).total_seconds() + if isinstance(statement1, datetime.date): + statement1=(statement1-datetime.date(1970,1,1)).total_seconds() + return statement1 + class PYSON(object): def pyson(self): @@ -313,7 +319,7 @@ super(Greater, self).__init__() for i in (statement1, statement2): if isinstance(i, PYSON): - assert i.types().issubset(set([int, long, float])), \ + assert i.types().issubset(set([int, long, float, datetime.date, datetime.datetime ])), \ 'statement must be an integer or a float' else: assert isinstance(i, (int, long, float)), \ @@ -346,7 +352,7 @@ for i in ('s1', 's2'): if not isinstance(dct[i], (int, long, float)): dct = dct.copy() - dct[i] = float(dct[i]) + dct[i] = float(date_to_float(dct[i])) return dct @staticmethod @@ -711,4 +717,3 @@ 'Len': Len, 'Id': Id, } - -- You received this message because you are subscribed to the Google Groups "tryton-dev" group. To view this discussion on the web visit https://groups.google.com/d/msgid/tryton-dev/0a6a0f55-027b-40a0-aae1-05d28a9a5f13%40googlegroups.com.