Raise error messages for missing currency exchange journal and accounts

This commit is contained in:
Cédric Krier
2023-05-10 14:57:42 +02:00
parent 681988e9dd
commit 1b165ac4bd
2 changed files with 26 additions and 0 deletions
+9
View File
@@ -178,6 +178,15 @@ You may need to cancel its move "%(move)s".</field>
<record model="ir.message" id="msg_reconciliation_write_off_missing">
<field name="text">To reconcile lines with "%(amount)s" write-off, you must select a write-off method.</field>
</record>
<record model="ir.message" id="msg_reconciliation_currency_exchange_journal_missing">
<field name="text">To reconcile lines, you must define a currency exchange journal for "%(company)s".</field>
</record>
<record model="ir.message" id="msg_reconciliation_currency_exchange_credit_account_missing">
<field name="text">To reconcile lines, you must define a currency exchange credit account for "%(company)s".</field>
</record>
<record model="ir.message" id="msg_reconciliation_currency_exchange_debit_account_missing">
<field name="text">To reconcile lines, you must define a currency exchange debit account for "%(company)s".</field>
</record>
<record model="ir.message" id="msg_line_debit_credit">
<field name="text">You cannot set both debit and credit on the line.</field>
+17
View File
@@ -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