From 1b165ac4bdfbe285f13340839626f00902f19e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 10 May 2023 14:57:42 +0200 Subject: [PATCH] Raise error messages for missing currency exchange journal and accounts --- modules/account/message.xml | 9 +++++++++ modules/account/move.py | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/modules/account/message.xml b/modules/account/message.xml index 1f3205eefc..9c938c9def 100644 --- a/modules/account/message.xml +++ b/modules/account/message.xml @@ -178,6 +178,15 @@ You may need to cancel its move "%(move)s". To reconcile lines with "%(amount)s" write-off, you must select a write-off method. + + To reconcile lines, you must define a currency exchange journal for "%(company)s". + + + To reconcile lines, you must define a currency exchange credit account for "%(company)s". + + + To reconcile lines, you must define a currency exchange debit account for "%(company)s". + You cannot set both debit and credit on the line. diff --git a/modules/account/move.py b/modules/account/move.py index 0a4e31a3de..83eab31399 100644 --- a/modules/account/move.py +++ b/modules/account/move.py @@ -1641,6 +1641,11 @@ class Line(MoveLineMixin, ModelSQL, ModelView): move.company = company move.journal = configuration.get_multivalue( 'currency_exchange_journal', company=company.id) + if not move.journal: + raise ReconciliationError(gettext( + 'account.' + 'msg_reconciliation_currency_exchange_journal_missing', + company=company.rec_name)) move.period = period_id move.date = date @@ -1660,9 +1665,21 @@ class Line(MoveLineMixin, ModelSQL, ModelView): if line.credit: line.account = configuration.get_multivalue( 'currency_exchange_credit_account', company=company.id) + if not line.account: + raise ReconciliationError(gettext( + 'account.' + 'msg_reconciliation_currency_exchange_' + 'credit_account_missing', + company=company.rec_name)) else: line.account = configuration.get_multivalue( 'currency_exchange_debit_account', company=company.id) + if not line.account: + raise ReconciliationError(gettext( + 'account.' + 'msg_reconciliation_currency_exchange_' + 'debit_account_missing', + company=company.rec_name)) move.lines = lines return move