From d40631463822a4d39662bd02de9a6a62f4af687a Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 27 Oct 2016 12:51:44 +0200 Subject: [PATCH] [FIX] account_voucher: Wrong reconciliation of customer payments Steps to reproduce : 1. Create a new customer 2. Create an invoice with an amount of 50.- for this new customer and validate it 3. Create a refund with an amount of 70.- for the same customer and validate it 4. Create a Customer Payment for this customer and validate it. The Invoice will be paid with 50.- of the refund. 20.- are still on residual in the refund. 5. Create a new invoice with an amount of 50.- for the same customer. 6. Create a new Customer Payment for the same Customer and validate it. The Full Reconcile Boolean stays checked inspite of "Open Balance" of Refund amount is less than the Invoice amount. After the fix: Full Reconciliation Boolean doesn't get checked and Allocation amount on invoice journal item line should be same as Open balance of the Refund Journal Item. So Invoice stays open with Balance amount. opw:691577 --- addons/account_voucher/account_voucher.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 949239f8124..2d414569a5e 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -757,14 +757,15 @@ class account_voucher(osv.osv): move_lines_found.append(line.id) break #otherwise we will split the voucher amount on each line (by most old first) - total_credit += line.credit or 0.0 - total_debit += line.debit or 0.0 + total_credit += line.credit and line.amount_residual or 0.0 + total_debit += line.debit and line.amount_residual or 0.0 elif currency_id == line.currency_id.id: if line.amount_residual_currency == price: move_lines_found.append(line.id) break - total_credit += line.credit and line.amount_currency or 0.0 - total_debit += line.debit and line.amount_currency or 0.0 + line_residual = currency_pool.compute(cr, uid, company_currency, currency_id, abs(line.amount_residual), context=context_multi_currency) + total_credit += line.credit and line_residual or 0.0 + total_debit += line.debit and line_residual or 0.0 remaining_amount = price #voucher line creation