[14.0]account_ebics - fix stack trace when using Odoo OE statement import

This commit is contained in:
Luc De Meyer 2022-08-05 12:29:47 +02:00
parent 39e44626a3
commit 2a9bbada0c
2 changed files with 51 additions and 36 deletions

View File

@ -3,7 +3,7 @@
{ {
"name": "EBICS banking protocol", "name": "EBICS banking protocol",
"version": "14.0.1.0.3", "version": "14.0.1.0.4",
"license": "LGPL-3", "license": "LGPL-3",
"author": "Noviat", "author": "Noviat",
"website": "www.noviat.com", "website": "www.noviat.com",

View File

@ -168,44 +168,59 @@ class EbicsFile(models.Model):
return False return False
return True return True
def _process_result_action(self, res): def _process_result_action(self, res, parser="oca"):
notifications = [] notifications = []
st_line_ids = [] st_line_ids = []
statement_ids = [] statement_ids = []
if res.get("context"): sts_data = []
notifications = res["context"].get("notifications", []) if parser == "oca":
st_line_ids = res["context"].get("statement_line_ids", []) if res.get("context"):
if notifications: notifications = res["context"].get("notifications", [])
for notif in notifications: st_line_ids = res["context"].get("statement_line_ids", [])
parts = [] if notifications:
for k in ["type", "message", "details"]: for notif in notifications:
if notif.get(k): parts = []
msg = "{}: {}".format(k, notif[k]) for k in ["type", "message", "details"]:
parts.append(msg) if notif.get(k):
self.note_process += "\n".join(parts) msg = "{}: {}".format(k, notif[k])
parts.append(msg)
self.note_process += "\n".join(parts)
self.note_process += "\n"
self.note_process += "\n" self.note_process += "\n"
self.note_process += "\n" if st_line_ids:
if st_line_ids: self.flush()
self.flush() self.env.cr.execute(
self.env.cr.execute( """
""" SELECT DISTINCT
SELECT DISTINCT absl.statement_id,
absl.statement_id, abs.name, abs.date, abs.company_id,
abs.name, abs.date, abs.company_id, rc.name AS company_name
rc.name AS company_name FROM account_bank_statement_line absl
FROM account_bank_statement_line absl INNER JOIN account_bank_statement abs
INNER JOIN account_bank_statement abs ON abs.id = absl.statement_id
ON abs.id = absl.statement_id INNER JOIN res_company rc
INNER JOIN res_company rc ON rc.id = abs.company_id
ON rc.id = abs.company_id WHERE absl.id IN %s
WHERE absl.id IN %s ORDER BY date, company_id
ORDER BY date, company_id """,
""", (tuple(st_line_ids),),
(tuple(st_line_ids),), )
) sts_data = self.env.cr.dictfetchall()
sts_data = self.env.cr.dictfetchall() elif parser == "oe":
else: if res.get("res_id"):
sts_data = [] st_ids = res["res_id"]
else:
st_ids = res["domain"][2]
statements = self.env["account.bank.statement"].browse(st_ids)
for statement in statements:
sts_data.append(
{
"statement_id": statement.id,
"date": statement.date,
"name": statement.name,
"company_name": statement.company_id.name,
}
)
st_cnt = len(sts_data) st_cnt = len(sts_data)
if st_cnt: if st_cnt:
self.note_process += _("%s bank statements have been imported: ") % st_cnt self.note_process += _("%s bank statements have been imported: ") % st_cnt
@ -414,7 +429,7 @@ class EbicsFile(models.Model):
_("No financial journal found for Company Bank Account %s") _("No financial journal found for Company Bank Account %s")
% bank_account % bank_account
) )
return self._process_result_action(res) return self._process_result_action(res, parser="oe")
@staticmethod @staticmethod
def _unlink_camt053(self): def _unlink_camt053(self):