More user-friendly handling of simpleeval errors

The account module uses simpleeval to allow custom move templates.

When an error occurs in one of thos expressions the whole traceback is shown.

For example:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/simpleeval.py", line 431, in _eval_name
    return self.names[node.id]
KeyError: 'importesS10'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tryton/trytond/trytond/protocols/dispatcher.py", line 186, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/tryton/trytond/trytond/wizard/wizard.py", line 290, in execute
    return wizard._execute(state_name)
  File "/tryton/trytond/trytond/wizard/wizard.py", line 321, in _execute
    result = self._execute(transition())
  File "/tryton/trytond/trytond/wizard/wizard.py", line 316, in _execute
    do_result = do(action)
  File "/tryton/trytond/trytond/modules/account/move_template.py", line 330, in do_open_
    move = self.create_move()
  File "/tryton/trytond/trytond/modules/account/move_template.py", line 303, in create_move
    move = template.get_move(values)
  File "/tryton/trytond/trytond/modules/account/move_template.py", line 58, in get_move
    move.lines = [l.get_line(values) for l in self.lines]
  File "/tryton/trytond/trytond/modules/account/move_template.py", line 58, in <listcomp>
    move.lines = [l.get_line(values) for l in self.lines]
  File "/tryton/trytond/trytond/modules/analytic_account_move/move.py", line 139, in get_line
    line = super(MoveLineTemplate, self).get_line(values)
  File "/tryton/trytond/trytond/modules/account/move_template.py", line 194, in get_line
    functions={'Decimal': Decimal}, names=values)
  File "/usr/local/lib/python3.7/dist-packages/simpleeval.py", line 609, in simple_eval
    return s.eval(expr)
  File "/usr/local/lib/python3.7/dist-packages/simpleeval.py", line 332, in eval
    return self._eval(ast.parse(expr.strip()).body[0].value)
  File "/usr/local/lib/python3.7/dist-packages/simpleeval.py", line 343, in _eval
    return handler(node)
  File "/usr/local/lib/python3.7/dist-packages/simpleeval.py", line 443, in _eval_name
    raise NameNotDefined(node.id, self.expr)
simpleeval.NameNotDefined: 'importesS10' is not defined for expression 'importesS10 '

I propose we capture simpleeval expressions and raise a UserError with just the relevant error.

Something like: “The following error was found when evaluating expression: ‘importesS10’ is not defined for expression 'importesS10 '.”

Thoughts?

Makes sense. This something that some user should fix so we should show and undestanable message to them. Furthermore, your proposal will be in concordance with the modify cost price wizard

Feel free to submit a patch