[FIX] account_bank_statement_import_camt_oca: Fix exception case

For avoiding collapsing with other importers.
This commit is contained in:
Pedro M. Baeza
2020-08-06 14:18:21 +02:00
committed by Iryna Vyshnevska
parent bea747b95b
commit f81407666e
2 changed files with 6 additions and 3 deletions

View File

@@ -2,7 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{ {
"name": "CAMT Format Bank Statements Import", "name": "CAMT Format Bank Statements Import",
"version": "13.0.1.0.0", "version": "13.0.1.0.1",
"license": "AGPL-3", "license": "AGPL-3",
"author": "Therp BV, Odoo Community Association (OCA)", "author": "Therp BV, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/bank-statement-import", "website": "https://github.com/OCA/bank-statement-import",

View File

@@ -242,8 +242,11 @@ class CamtParser(models.AbstractModel):
try: try:
root = etree.fromstring(data, parser=etree.XMLParser(recover=True)) root = etree.fromstring(data, parser=etree.XMLParser(recover=True))
except etree.XMLSyntaxError: except etree.XMLSyntaxError:
try:
# ABNAmro is known to mix up encodings # ABNAmro is known to mix up encodings
root = etree.fromstring(data.decode("iso-8859-15").encode("utf-8")) root = etree.fromstring(data.decode("iso-8859-15").encode("utf-8"))
except etree.XMLSyntaxError:
root = None
if root is None: if root is None:
raise ValueError("Not a valid xml file, or not an xml file at all.") raise ValueError("Not a valid xml file, or not an xml file at all.")
ns = root.tag[1 : root.tag.index("}")] ns = root.tag[1 : root.tag.index("}")]