From 52a98f74f309338181fe8e4491905aaaec085bbe Mon Sep 17 00:00:00 2001 From: jev-odoo Date: Fri, 31 Jan 2020 14:04:26 +0000 Subject: [PATCH] [FIX] account: More information when missing account Before this fix, when default debit and credit account where not set on the journal, there was a simple error message saying that an account was missing on an invoice line: "Missing required account on accountable invoice line." Now, the error message tells on which journal the accounts are missing, giving better insight to the user. Update addons/account/i18n/account.pot Update addons/account/models/account_bank_statement.py closes odoo/odoo#48312 X-original-commit: bb4b707fbcafa54a2e8b8a6e73fbe102b8b13811 Signed-off-by: jev Co-authored-by: Richard Mathot Co-authored-by: Richard Mathot --- addons/account/models/account_bank_statement.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index 9e6bb38e292..251f438577c 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -646,12 +646,18 @@ class AccountBankStatementLine(models.Model): # last case is company in currency A, statement in currency A and transaction in currency A # and in this case counterpart line does not need any second currency nor amount_currency + # Check if default_debit or default_credit account are properly configured + account_id = amount >= 0 \ + and self.statement_id.journal_id.default_credit_account_id.id \ + or self.statement_id.journal_id.default_debit_account_id.id + + if not account_id: + raise UserError(_('No default debit and credit account defined on journal %s (ids: %s).' % (self.statement_id.journal_id.name, self.statement_id.journal_id.ids))) + aml_dict = { 'name': self.name, 'partner_id': self.partner_id and self.partner_id.id or False, - 'account_id': amount >= 0 \ - and self.statement_id.journal_id.default_credit_account_id.id \ - or self.statement_id.journal_id.default_debit_account_id.id, + 'account_id': account_id, 'credit': amount < 0 and -amount or 0.0, 'debit': amount > 0 and amount or 0.0, 'statement_line_id': self.id,