diff --git a/account_banking/banking_import_transaction.py b/account_banking/banking_import_transaction.py index aad6cc8a8..da70a274c 100644 --- a/account_banking/banking_import_transaction.py +++ b/account_banking/banking_import_transaction.py @@ -140,7 +140,8 @@ class banking_import_transaction(osv.osv): limit=0, context=context) orders = payment_order_obj.browse(cr, uid, order_ids, context) candidates = [x for x in orders if - is_zero(x.total - trans.transferred_amount)] + is_zero(x.total - trans.transferred_amount) and + x.line_ids and x.line_ids[0].debit_move_line_id] if len(candidates) > 0: # retrieve the common account_id, if any account_id = False @@ -374,7 +375,7 @@ class banking_import_transaction(osv.osv): move_line = False partial = False - elif len(candidates) == 1: + elif len(candidates) == 1 and candidates[0].invoice: # Mismatch in amounts move_line = candidates[0] invoice = move_line.invoice @@ -422,10 +423,10 @@ class banking_import_transaction(osv.osv): if x.partner_id.id == move_line.partner_id.id ] - return (trans, self._get_move_info( - cr, uid, [move_line.id], - account_ids and account_ids[0] or False), - trans2) + return (trans, self._get_move_info( + cr, uid, [move_line.id], + account_ids and account_ids[0] or False), + trans2) return trans, False, False @@ -1056,7 +1057,7 @@ 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'] = [x.invoice.id for x in move_lines] + retval['invoice_ids'] = list(set([x.invoice.id for x in move_lines])) retval['type'] = type_map[move_lines[0].invoice.type] return retval diff --git a/account_banking_nl_clieop/wizard/clieop.py b/account_banking_nl_clieop/wizard/clieop.py index 79e56f0d1..25f52982a 100644 --- a/account_banking_nl_clieop/wizard/clieop.py +++ b/account_banking_nl_clieop/wizard/clieop.py @@ -43,6 +43,11 @@ class SWIFTField(record.Field): #def format(self, value): # return convert.to_swift(super(SWIFTField, self).format(value)) +class SWIFTFieldNoLeadingWhitespace(SWIFTField): + def format(self, value): + return super(SWIFTFieldNoLeadingWhitespace, self).format( + self.cast(value).lstrip()) + def eleven_test(s): ''' Dutch eleven-test for validating 9-long local bank account numbers. @@ -161,7 +166,7 @@ class PaymentReferenceRecord(record.Record): _fields = [ record.Filler('recordcode', 4, '0150'), record.Filler('variantcode', 1, 'A'), - SWIFTField('paymentreference', 16), + SWIFTFieldNoLeadingWhitespace('paymentreference', 16), record.Filler('filler', 29), ]