[FIX] avoid linking to the same invoice twice

[FIX] don't choke on order line without debit moves
[FIX] seems like some fields in clieop can't start with a space
[FIX] only employ partial matching on move lines with an invoice attached
[FIX] only return matched invoice if we have a matched invoice
This commit is contained in:
Holger Brunn
2013-04-02 13:27:53 +02:00
committed by Guewen Baconnier
2 changed files with 14 additions and 8 deletions

View File

@@ -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

View File

@@ -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),
]