Raise user error when description of move template can not be formatted
Closes #13240
This commit is contained in:
@@ -139,6 +139,9 @@ this repository contains the full copyright notices and license terms. -->
|
||||
Use the current period to cancel the move?</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.message" id="msg_move_template_invalid_description">
|
||||
<field name="text">Failed to evaluate the description "%(description)s" from template "%(template)s" with error: "%(error)s"</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_move_template_invalid_expression">
|
||||
<field name="text">Failed to evaluate expression "%(expression)s" from template "%(template)s" with error:
|
||||
"%(error)s"</field>
|
||||
|
||||
@@ -55,8 +55,16 @@ class MoveTemplate(DeactivableMixin, ModelSQL, ModelView):
|
||||
move.company = self.company
|
||||
move.journal = self.journal
|
||||
if self.description:
|
||||
move.description = self.description.format(
|
||||
**dict(Keyword.format_values(self, values)))
|
||||
try:
|
||||
move.description = self.description.format(
|
||||
**dict(Keyword.format_values(self, values)))
|
||||
except (KeyError, ValueError) as e:
|
||||
raise MoveTemplateExpressionError(
|
||||
gettext(
|
||||
'account.msg_move_template_invalid_description',
|
||||
description=self.description,
|
||||
template=self.rec_name,
|
||||
error=e)) from e
|
||||
move.lines = [l.get_line(values) for l in self.lines]
|
||||
|
||||
return move
|
||||
|
||||
Reference in New Issue
Block a user