[FIX] account_voucher: make sure we do not match move lines that are totally used...
authorXavier ALT <xal@openerp.com>
Wed, 5 Dec 2012 18:02:05 +0000 (19:02 +0100)
committerXavier ALT <xal@openerp.com>
Wed, 5 Dec 2012 18:02:05 +0000 (19:02 +0100)
bzr revid: xal@openerp.com-20121205180205-yhto5g6g2p63jm65

addons/account_voucher/account_voucher.py

index a278f2e..49b2708 100644 (file)
@@ -481,6 +481,9 @@ class account_voucher(osv.osv):
             total_credit = currency_pool.compute(cr, uid, currency_id, company_currency, total_credit, context=context_multi_currency)
 
         for line in moves:
+            if line.reconcile_partial_id and line.amount_residual_currency < 0:
+                # skip line that are totally used within partial reconcile
+                continue
             if invoice_id:
                 if line.invoice.id == invoice_id:
                     #if the invoice linked to the voucher line is equal to the invoice_id in context
@@ -504,6 +507,9 @@ class account_voucher(osv.osv):
                 total_credit += line.credit and line.amount_currency or 0.0
                 total_debit += line.debit and line.amount_currency or 0.0
         for line in moves:
+            if line.reconcile_partial_id and line.amount_residual_currency < 0:
+                # skip line that are totally used within partial reconcile
+                continue
             original_amount = line.credit or line.debit or 0.0
             amount_unreconciled = currency_pool.compute(cr, uid, line.currency_id and line.currency_id.id or company_currency, currency_id, abs(line.amount_residual_currency), context=context_multi_currency)
             line_currency_id = line.currency_id and line.currency_id.id or company_currency