mirror of
https://github.com/brain-tec/account_ebics.git
synced 2024-11-23 12:42:04 +00:00
Merge pull request #64 from Noviat/15-fix-oca-camt
15.0 - fix for recent OCA account_statement_import_camt
This commit is contained in:
commit
46557433de
@ -1,9 +1,9 @@
|
|||||||
# Copyright 2009-2022 Noviat.
|
# Copyright 2009-2023 Noviat.
|
||||||
# License LGPL-3 or later (http://www.gnu.org/licenses/lpgl).
|
# License LGPL-3 or later (http://www.gnu.org/licenses/lpgl).
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "EBICS banking protocol",
|
"name": "EBICS banking protocol",
|
||||||
"version": "15.0.1.1.0",
|
"version": "15.0.1.1.1",
|
||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
"author": "Noviat",
|
"author": "Noviat",
|
||||||
"website": "https://www.noviat.com",
|
"website": "https://www.noviat.com",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright 2009-2022 Noviat.
|
# Copyright 2009-2023 Noviat.
|
||||||
# License LGPL-3 or later (http://www.gnu.org/licenses/lpgl).
|
# License LGPL-3 or later (http://www.gnu.org/licenses/lpgl).
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
@ -264,10 +264,6 @@ class EbicsFile(models.Model):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _process_cfonb120(self):
|
def _process_cfonb120(self):
|
||||||
"""
|
|
||||||
We do not support the standard _journal_creation_wizard since a single
|
|
||||||
cfonb120 file may contain statements from different legal entities.
|
|
||||||
"""
|
|
||||||
import_module = "account_statement_import_fr_cfonb"
|
import_module = "account_statement_import_fr_cfonb"
|
||||||
self._check_import_module(import_module)
|
self._check_import_module(import_module)
|
||||||
wiz_model = "account.statement.import"
|
wiz_model = "account.statement.import"
|
||||||
@ -415,34 +411,81 @@ class EbicsFile(models.Model):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
if _src == "oca":
|
if _src == "oca":
|
||||||
self._process_camt053_oca()
|
return self._process_camt053_oca()
|
||||||
else:
|
else:
|
||||||
self._process_camt053_oe()
|
return self._process_camt053_oe()
|
||||||
|
|
||||||
def _process_camt053_oca(self):
|
def _process_camt053_oca(self):
|
||||||
|
"""
|
||||||
|
TODO: merge common logic of this method and _process_cfonb120
|
||||||
|
"""
|
||||||
wiz_model = "account.statement.import"
|
wiz_model = "account.statement.import"
|
||||||
wiz_vals = {
|
wiz_vals = {
|
||||||
"statement_filename": self.name,
|
"statement_filename": self.name,
|
||||||
"statement_file": self.data,
|
"statement_file": self.data,
|
||||||
}
|
}
|
||||||
|
result_action = self.env["ir.actions.act_window"]._for_xml_id(
|
||||||
|
"account.action_bank_statement_tree"
|
||||||
|
)
|
||||||
|
result_action["context"] = safe_eval(result_action["context"])
|
||||||
result = {
|
result = {
|
||||||
"type": "ir.actions.client",
|
"statement_ids": [],
|
||||||
"tag": "bank_statement_reconciliation_view",
|
"notifications": [],
|
||||||
"context": {
|
|
||||||
"statement_line_ids": [],
|
|
||||||
"company_ids": self.env.user.company_ids.ids,
|
|
||||||
"notifications": [],
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
statement_ids = []
|
||||||
|
notifications = []
|
||||||
wiz = (
|
wiz = (
|
||||||
self.env[wiz_model].with_context(active_model="ebics.file").create(wiz_vals)
|
self.env[wiz_model].with_context(active_model="ebics.file").create(wiz_vals)
|
||||||
)
|
)
|
||||||
res = wiz.import_file_button()
|
msg_hdr = _(
|
||||||
result["context"]["statement_line_ids"].extend(
|
"{} : Import failed for EBICS File %(fn)s:\n",
|
||||||
res["context"]["statement_line_ids"]
|
fn=wiz.statement_filename,
|
||||||
)
|
)
|
||||||
result["context"]["notifications"].extend(res["context"]["notifications"])
|
try:
|
||||||
return self._process_result_action(result)
|
with self.env.cr.savepoint():
|
||||||
|
file_data = base64.b64decode(self.data)
|
||||||
|
wiz.import_single_file(file_data, result)
|
||||||
|
|
||||||
|
if not result["statement_ids"]:
|
||||||
|
message = msg_hdr.format(_("Warning"))
|
||||||
|
message += _(
|
||||||
|
"You have already imported this file, or this file "
|
||||||
|
"only contains already imported transactions."
|
||||||
|
)
|
||||||
|
notifications += [
|
||||||
|
{
|
||||||
|
"type": "warning",
|
||||||
|
"message": message,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
statement_ids.extend(result["statement_ids"])
|
||||||
|
notifications.extend(result["notifications"])
|
||||||
|
|
||||||
|
except UserError as e:
|
||||||
|
message = msg_hdr.format(_("Error"))
|
||||||
|
message += "".join(e.args)
|
||||||
|
notifications += [
|
||||||
|
{
|
||||||
|
"type": "error",
|
||||||
|
"message": message,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
tb = "".join(format_exception(*exc_info()))
|
||||||
|
message = msg_hdr.format(_("Error"))
|
||||||
|
message += tb
|
||||||
|
notifications += [
|
||||||
|
{
|
||||||
|
"type": "error",
|
||||||
|
"message": message,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
result_action["context"]["notifications"] = notifications
|
||||||
|
result_action["domain"] = [("id", "in", statement_ids)]
|
||||||
|
return self._process_result_action(result_action)
|
||||||
|
|
||||||
def _process_camt053_oe(self):
|
def _process_camt053_oe(self):
|
||||||
wiz_model = "account.bank.statement.import"
|
wiz_model = "account.bank.statement.import"
|
||||||
|
Loading…
Reference in New Issue
Block a user