diff --git a/account_ebics/__manifest__.py b/account_ebics/__manifest__.py index 63c1813..53e1ca9 100644 --- a/account_ebics/__manifest__.py +++ b/account_ebics/__manifest__.py @@ -3,7 +3,7 @@ { "name": "EBICS banking protocol", - "version": "15.0.1.1.1", + "version": "15.0.1.1.2", "license": "LGPL-3", "author": "Noviat", "website": "https://www.noviat.com", diff --git a/account_ebics/models/ebics_file.py b/account_ebics/models/ebics_file.py index 7b07792..6751502 100644 --- a/account_ebics/models/ebics_file.py +++ b/account_ebics/models/ebics_file.py @@ -87,7 +87,7 @@ class EbicsFile(models.Model): return super(EbicsFile, self).unlink() def set_to_draft(self): - return self.write({"state": "draft"}) + return self.write({"state": "draft", "note": False}) def set_to_done(self): return self.write({"state": "done"}) @@ -219,10 +219,11 @@ class EbicsFile(models.Model): error_cnt += 1 elif notif["type"] == "warning": warning_cnt += 1 - parts = [notif[k] for k in notif if k in ("message", "details")] + parts = [ + notif[k] for k in notif if k in ("message", "details") and notif[k] + ] self.note_process += "\n".join(parts) self.note_process += "\n\n" - self.note_process += "\n" if error_cnt: self.note_process += ( _("Number of errors detected during import: %s: ") % error_cnt @@ -233,8 +234,9 @@ class EbicsFile(models.Model): _("Number of watnings detected during import: %s: ") % warning_cnt ) if st_cnt: - self.note_process += "\n\n" - self.note_process += _("%s bank statements have been imported: ") % st_cnt + if self.note_process: + self.note_process += "\n\n" + self.note_process += _("%s bank statement(s) have been imported: ") % st_cnt self.note_process += "\n" for st_data in sts_data: self.note_process += ("\n%s, %s (%s)") % ( @@ -293,6 +295,8 @@ class EbicsFile(models.Model): "account.action_bank_statement_tree" ) result_action["context"] = safe_eval(result_action["context"]) + + transactions = False statement_ids = [] notifications = [] for i, wiz_vals in enumerate(wiz_vals_list, start=1): @@ -315,7 +319,10 @@ class EbicsFile(models.Model): fn=statement_filename, ) wiz.import_single_file(file_data, result) - if not result["statement_ids"]: + if result["statement_ids"]: + transactions = True + statement_ids.extend(result["statement_ids"]) + elif not result.get("no_transactions"): message = msg_hdr.format(_("Warning")) message += _( "You have already imported this file, or this file " @@ -327,8 +334,7 @@ class EbicsFile(models.Model): "message": message, } ] - else: - statement_ids.extend(result["statement_ids"]) + transactions = True notifications.extend(result["notifications"]) except UserError as e: @@ -352,6 +358,10 @@ class EbicsFile(models.Model): } ] + if not transactions: + message = _("This file doesn't contain any transaction.") + notifications = [{"type": "warning", "message": message, "details": ""}] + self.note = message result_action["context"]["notifications"] = notifications result_action["domain"] = [("id", "in", statement_ids)] return self._process_result_action(result_action) diff --git a/account_ebics_oca_statement_import/__manifest__.py b/account_ebics_oca_statement_import/__manifest__.py index 735313c..a792d7c 100644 --- a/account_ebics_oca_statement_import/__manifest__.py +++ b/account_ebics_oca_statement_import/__manifest__.py @@ -1,10 +1,10 @@ -# Copyright 2020-2022 Noviat. +# Copyright 2009-2023 Noviat. # License LGPL-3 or later (http://www.gnu.org/licenses/lpgl). { "name": "account_ebics with OCA Bank Statement Imoort", "summary": "Use OCA Bank Statement Import with account_ebics", - "version": "15.0.1.0.0", + "version": "15.0.1.0.1", "author": "Noviat", "website": "https://www.noviat.com", "category": "Hidden", 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 86b798d..c344a76 100644 --- a/account_ebics_oca_statement_import/wizards/account_statement_import.py +++ b/account_ebics_oca_statement_import/wizards/account_statement_import.py @@ -1,4 +1,4 @@ -# Copyright 2009-2020 Noviat. +# Copyright 2009-2023 Noviat. # License LGPL-3 or later (http://www.gnu.org/licenses/lpgl). import logging @@ -53,8 +53,9 @@ class AccountStatementImport(models.TransientModel): 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] + result["notifications"].append( + {"type": "warning", "message": message, "details": ""} + ) + result["no_transactions"] = True return super()._create_bank_statements(stmts_vals, result)