From bd4c7f0cfd5fb607188cf6ef11f47e2eb1b5e978 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 6 May 2013 09:37:44 +0200 Subject: [PATCH 1/3] [FIX] get type from a move line that has an invoice [IMP] only pass invoice_ids that actually are invoice_ids --- account_banking/banking_import_transaction.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/account_banking/banking_import_transaction.py b/account_banking/banking_import_transaction.py index 50fa9294a..0215b7ad4 100644 --- a/account_banking/banking_import_transaction.py +++ b/account_banking/banking_import_transaction.py @@ -1048,6 +1048,7 @@ class banking_import_transaction(osv.osv): break else: retval['match_type'] = 'invoice' + retval['type'] = type_map[move_line.invoice.type] else: if retval['match_type']: retval['match_type'] = False @@ -1057,8 +1058,8 @@ class banking_import_transaction(osv.osv): if move_lines and len(move_lines) == 1: retval['reference'] = move_lines[0].ref if retval['match_type'] == 'invoice': - retval['invoice_ids'] = list(set([x.invoice.id for x in move_lines])) - retval['type'] = type_map[move_lines[0].invoice.type] + retval['invoice_ids'] = list(set( + [x.invoice.id for x in move_lines if x.invoice])) return retval def match(self, cr, uid, ids, results=None, context=None): From 6195846934b8f1339c2e796fe8f389a75c4d1a3a Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 6 May 2013 12:07:19 +0200 Subject: [PATCH 2/3] [FIX] the semantics of match_type returned by _get_move_info is meant to be 'there are only matches of this type', but there were several cases where this didn't hold --- account_banking/banking_import_transaction.py | 68 +++++++------------ 1 file changed, 26 insertions(+), 42 deletions(-) diff --git a/account_banking/banking_import_transaction.py b/account_banking/banking_import_transaction.py index 0215b7ad4..dd2146b26 100644 --- a/account_banking/banking_import_transaction.py +++ b/account_banking/banking_import_transaction.py @@ -1016,50 +1016,34 @@ class banking_import_transaction(osv.osv): 'account_id': False, } move_lines = self.pool.get('account.move.line').browse(cr, uid, move_line_ids) - for move_line in move_lines: - if move_line.partner_id: - if retval['partner_id']: - if retval['partner_id'] != move_line.partner_id.id: - retval['partner_id'] = False - break - else: - retval['partner_id'] = move_line.partner_id.id - else: - if retval['partner_id']: - retval['partner_id'] = False - break - for move_line in move_lines: - if move_line.account_id: - if retval['account_id']: - if retval['account_id'] != move_line.account_id.id: - retval['account_id'] = False - break - else: - retval['account_id'] = move_line.account_id.id - else: - if retval['account_id']: - retval['account_id'] = False - break - for move_line in move_lines: - if move_line.invoice: - if retval['match_type']: - if retval['match_type'] != 'invoice': - retval['match_type'] = False - break - else: - retval['match_type'] = 'invoice' - retval['type'] = type_map[move_line.invoice.type] - else: - if retval['match_type']: - retval['match_type'] = False - break - if move_lines and not retval['match_type']: + + if not move_lines: + return retval + + if move_lines[0].partner_id and all( + [move_line.partner_id == move_lines[0].partner_id + for move_line in move_lines): + retval['partner_id'] = move_lines[0].partner_id.id + + if move_lines[0].account_id and all( + [move_line.account_id == move_lines[0].account_id + for move_line in move_lines]): + retval['account_id'] = move_lines[0].account_id.id + + if move_lines[0].invoice and all( + [move_line.invoice == move_lines[0].invoice + for move_line in move_lines]): + retval['match_type'] = 'invoice' + retval['type'] = type_map[move_lines[0].invoice.type] + retval['invoice_ids'] = list( + set([x.invoice.id for x in move_lines)) + + if not retval['match_type']: retval['match_type'] = 'move' - if move_lines and len(move_lines) == 1: + + if len(move_lines) == 1: retval['reference'] = move_lines[0].ref - if retval['match_type'] == 'invoice': - retval['invoice_ids'] = list(set( - [x.invoice.id for x in move_lines if x.invoice])) + return retval def match(self, cr, uid, ids, results=None, context=None): From 000439be51e70628d845ecbfab531458ac63ffb7 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 20 May 2013 10:07:48 +0200 Subject: [PATCH 3/3] [FIX] add closing brackets where they belong --- account_banking/banking_import_transaction.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/account_banking/banking_import_transaction.py b/account_banking/banking_import_transaction.py index dd2146b26..1f03f756b 100644 --- a/account_banking/banking_import_transaction.py +++ b/account_banking/banking_import_transaction.py @@ -1022,7 +1022,7 @@ class banking_import_transaction(osv.osv): if move_lines[0].partner_id and all( [move_line.partner_id == move_lines[0].partner_id - for move_line in move_lines): + for move_line in move_lines]): retval['partner_id'] = move_lines[0].partner_id.id if move_lines[0].account_id and all( @@ -1036,7 +1036,7 @@ class banking_import_transaction(osv.osv): retval['match_type'] = 'invoice' retval['type'] = type_map[move_lines[0].invoice.type] retval['invoice_ids'] = list( - set([x.invoice.id for x in move_lines)) + set([x.invoice.id for x in move_lines])) if not retval['match_type']: retval['match_type'] = 'move'