Since 8c3da23d1fb4 changed safe_eval o eval (1)

I try eval a trigger (same eval that I use in 3.4) and I get error
current version. How to eval with new API? What am I missing?

Example to eval:

self.name == 'Test'

Traceback (most recent call last):
  File "/trytond/protocols/jsonrpc.py", line 162, in _marshaled_dispatch
    response['result'] = dispatch_method(method, params)
  File "/trytond/protocols/jsonrpc.py", line 191, in _dispatch
    res = dispatch(*args)
  File "/trytond/protocols/dispatcher.py", line 158, in dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/trytond/model/modelsql.py", line 764, in write
    trigger_eligibles = cls.trigger_write_get_eligibles(records)
  File "/trytond/model/modelstorage.py", line 192, in
trigger_write_get_eligibles
    if not Trigger.eval(trigger, record):
  File "/trytond/ir/trigger.py", line 177, in eval
    return bool(PYSONDecoder(env).decode(trigger.condition))
  File "/dist-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/dist-packages/simplejson/decoder.py", line 389, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Note:

EvalEnvironment when process this values:

party.party,2 <class 'trytond.pool.party.party'>

return a empty dict:

{}

Here there is env PYSONDecorde:

{'current_date': datetime.datetime(2015, 7, 13, 9, 37, 7, 23151),
'self': {}, 'context': {'date_format': '%d/%m/%Y', 'language':
'ca_ES', 'locale': {'date': '%d/%m/%Y', 'thousands_sep': ' ',
'decimal_point': ',', 'grouping': [3, 3, 0]}, 'language_direction':
'ltr', '_check_access': True, 'company.rec_name': 'zz', 'groups': [1,
5, 2, 3, 7, 6, 4, 8], 'employee': None, 'company': 1}, 'time': <module
'time' (built-in)>}

(1) http://hg.tryton.org/trytond/rev/8c3da23d1fb4
(2) http://hg.tryton.org/trytond/file/1ee266149d72/trytond/ir/trigger.py#l174

Reply via email to