diff --git a/modules/account/message.xml b/modules/account/message.xml index 57a27ae16a..34542b7ba2 100644 --- a/modules/account/message.xml +++ b/modules/account/message.xml @@ -139,6 +139,9 @@ this repository contains the full copyright notices and license terms. --> Use the current period to cancel the move? + + Failed to evaluate the description "%(description)s" from template "%(template)s" with error: "%(error)s" + Failed to evaluate expression "%(expression)s" from template "%(template)s" with error: "%(error)s" diff --git a/modules/account/move_template.py b/modules/account/move_template.py index e0ff2119b5..c548b8e981 100644 --- a/modules/account/move_template.py +++ b/modules/account/move_template.py @@ -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