Validate keywords for account move template
(Tested in develop)
- Install account module (and its dependencies)
- Create a period
- Create an account.move.template (Financial/Configuration/Templates/Moves)
- Add a Journal
- Create a keyword (the keyword must have a name with spaces)
- For the example, we create a keyword with the values:
- Name: NAME WITH SPACES
- String: NAME WITH SPACES
- Type: Numeric
- Digits: 2
- Required: False
- Create a line where we use the keyword we create
- Save
- If we execute the wizard "Create Move from Template" (Financial/Entries/Create Move from Template) and select the Move template we created, add a value and press "Create" a traceback appears:
Traceback (most recent call last):
File "/trytond/wsgi.py", line 109, in dispatch_request
return endpoint(request, **request.view_args)
File "/trytond/protocols/dispatcher.py", line 42, in rpc
return methods.get(request.rpc_method, _dispatch)(
File "/trytond/wsgi.py", line 76, in auth_required
return wrapped(*args, **kwargs)
File "/trytond/protocols/wrappers.py", line 178, in wrapper
return func(request, pool, *args, **kwargs)
File "/trytond/protocols/dispatcher.py", line 200, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/trytond/wizard/wizard.py", line 328, in execute
return wizard._execute(state_name)
File "/trytond/wizard/wizard.py", line 361, in _execute
result = self._execute(transition())
File "/trytond/wizard/wizard.py", line 356, in _execute
do_result = do(action)
File "/trytond/modules/account/move_template.py", line 385, in do_open_
move = self.create_move()
File "/trytond/modules/account/move_template.py", line 360, in create_move
move = template.get_move(values)
File "/trytond/modules/account/move_template.py", line 61, in get_move
move.lines = [l.get_line(values) for l in self.lines]
File "/trytond/modules/account/move_template.py", line 61, in <listcomp>
move.lines = [l.get_line(values) for l in self.lines]
File "/trytond/modules/account/move_template.py", line 208, in get_line
amount = simple_eval(decistmt(self.amount),
File "/simpleeval.py", line 683, in simple_eval
return s.eval(expr)
File "/simpleeval.py", line 389, in eval
return self._eval(ast.parse(expr.strip()).body[0])
File "/ast.py", line 50, in parse
return compile(source, filename, mode, flags,
File "<unknown>", line 1
TEST WITH SPACES
^
SyntaxError: invalid syntax
- The traceback appears because the keyword name of the template have withe space. (Apart from the white spaces, we can find other errors when creating the name of a keyword)
I think we need to check if the keyword is correct when we created it (maybe use python "isidentifier()" (https://docs.python.org/3/library/stdtypes.html?#str.isidentifier)).