From d62713d06f9d49733bc18f8a0932752fb31e9c85 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 8 Aug 2018 08:34:43 +0200 Subject: [PATCH] [FIX] don't cause a warning for the data key (#148) --- .../models/parser.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/account_bank_statement_import_camt/models/parser.py b/account_bank_statement_import_camt/models/parser.py index 6c4e188..0adf319 100644 --- a/account_bank_statement_import_camt/models/parser.py +++ b/account_bank_statement_import_camt/models/parser.py @@ -185,12 +185,14 @@ class CamtParser(models.AbstractModel): self.parse_transaction_details(ns, dnode, transaction) # transactions['data'] should be a synthetic xml snippet which # contains only the TxDtls that's relevant. - data = copy(node) - for j, dnode in enumerate(data.xpath( - './ns:NtryDtls/ns:TxDtls', namespaces={'ns': ns})): - if j != i: - dnode.getparent().remove(dnode) - transaction['data'] = etree.tostring(data) + # only set this field if statement lines have it + if 'data' in self.pool['account.bank.statement.line']._fields: + data = copy(node) + for j, dnode in enumerate(data.xpath( + './ns:NtryDtls/ns:TxDtls', namespaces={'ns': ns})): + if j != i: + dnode.getparent().remove(dnode) + transaction['data'] = etree.tostring(data) yield transaction def get_balance_amounts(self, ns, node):