mirror of
https://github.com/brain-tec/account_ebics.git
synced 2024-11-23 12:42:04 +00:00
Merge pull request #82 from Noviat/15-imp-empty-statements
[IMP] improved handling of statements without transactions
This commit is contained in:
commit
ccb8936e14
@ -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",
|
||||
|
@ -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:
|
||||
if self.note_process:
|
||||
self.note_process += "\n\n"
|
||||
self.note_process += _("%s bank statements have been imported: ") % st_cnt
|
||||
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)
|
||||
|
@ -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",
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user