From 95acd0dd707f53c7816c29ec2b8936c00112bc82 Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Thu, 3 Aug 2023 23:42:58 +0200 Subject: [PATCH] account_ebics 16.0 : add support for CFONB --- .../wizards/account_statement_import.py | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/account_ebics_oca_statement_import/wizards/account_statement_import.py b/account_ebics_oca_statement_import/wizards/account_statement_import.py index f4eb9e5..9615723 100644 --- a/account_ebics_oca_statement_import/wizards/account_statement_import.py +++ b/account_ebics_oca_statement_import/wizards/account_statement_import.py @@ -46,15 +46,35 @@ class AccountStatementImport(models.TransientModel): show days without transactions via the bank statement list view. """ if self.env.context.get("active_model") == "ebics.file": + messages = [] transactions = False for st_vals in stmts_vals: + statement_ids = result["statement_ids"][:] + self._set_statement_name(st_vals) if st_vals.get("transactions"): transactions = True - break - if not transactions: - message = _("This file doesn't contain any transaction.") - st_line_ids = [] - notifications = {"type": "warning", "message": message, "details": ""} - return st_line_ids, [notifications] + super()._create_bank_statements(stmts_vals, result) + if result["statement_ids"] == statement_ids: + # no statement has been created, this is the case + # when all transactions have been imported already + messages.append( + _( + "Statement %(st_name)s dated %(date)s " + "has already been imported.", + st_name=st_vals["name"], + date=st_vals["date"].strftime("%Y-%m-%d"), + ) + ) - return super()._create_bank_statements(stmts_vals, result) + if not transactions: + messages.append(_("This file doesn't contain any transaction.")) + if messages: + result["notifications"].append( + {"type": "warning", "message": "\n".join(messages)} + ) + return + + def _set_statement_name(self, st_vals): + """ + Inherit this method to set your own statement naming policy. + """