mirror of
https://github.com/brain-tec/account_ebics.git
synced 2026-08-06 14:42:37 +00:00
[FIX]account_ebics_oca_statement_import - fix stack trace
Fix stack trace when importing csv file on financial journal without bank account number. This PR optimises also the _match_journal() method in the import wizard.
This commit is contained in:
@@ -15,25 +15,25 @@ class AccountStatementImport(models.TransientModel):
|
|||||||
_inherit = "account.statement.import"
|
_inherit = "account.statement.import"
|
||||||
|
|
||||||
def _match_journal(self, account_number, currency):
|
def _match_journal(self, account_number, currency):
|
||||||
journal = self.env["account.journal"]
|
if not account_number:
|
||||||
|
return super()._match_journal(account_number, currency)
|
||||||
sanitized_account_number = self._sanitize_account_number(account_number)
|
sanitized_account_number = self._sanitize_account_number(account_number)
|
||||||
fin_journals = self.env["account.journal"].search(
|
fin_journal = self.env["account.journal"].search(
|
||||||
[
|
[
|
||||||
("type", "=", "bank"),
|
("type", "=", "bank"),
|
||||||
|
(
|
||||||
|
"bank_account_id.sanitized_acc_number",
|
||||||
|
"like",
|
||||||
|
sanitized_account_number,
|
||||||
|
),
|
||||||
"|",
|
"|",
|
||||||
("currency_id", "=", currency.id),
|
("currency_id", "=", currency.id),
|
||||||
("company_id.currency_id", "=", currency.id),
|
("company_id.currency_id", "=", currency.id),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
fin_journal = fin_journals.filtered(
|
|
||||||
lambda r: sanitized_account_number
|
|
||||||
in (r.bank_account_id.sanitized_acc_number or "")
|
|
||||||
)
|
|
||||||
if len(fin_journal) == 1:
|
if len(fin_journal) == 1:
|
||||||
journal = fin_journal
|
return fin_journal
|
||||||
if not journal:
|
return super()._match_journal(account_number, currency)
|
||||||
journal = super()._match_journal(account_number, currency)
|
|
||||||
return journal
|
|
||||||
|
|
||||||
def _sanitize_account_number(self, account_number):
|
def _sanitize_account_number(self, account_number):
|
||||||
sanitized_number = sanitize_account_number(account_number)
|
sanitized_number = sanitize_account_number(account_number)
|
||||||
|
|||||||
Reference in New Issue
Block a user