From 086c85200f01b7acd8fed771b3f46d1b32b9acaf Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Tue, 10 Jul 2018 16:20:13 -0700 Subject: [PATCH] FIX Random residual mutation during computation. Additionally: I do not know why watching `invoice_id.residual` causes this to happen, seemingly nothing in this method did anything to explain it (i.e. the refactor on line 78 didn't help but I decided to leave it) Best guess would be some part of the core trying to decide which invoices to pay. --- account_payment_disperse/wizard/register_payment_wizard.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/account_payment_disperse/wizard/register_payment_wizard.py b/account_payment_disperse/wizard/register_payment_wizard.py index 465dd5c3..38861838 100644 --- a/account_payment_disperse/wizard/register_payment_wizard.py +++ b/account_payment_disperse/wizard/register_payment_wizard.py @@ -60,7 +60,7 @@ class AccountRegisterPaymentsInvoiceLine(models.TransientModel): amount = fields.Float(string='Amount') writeoff_acc_id = fields.Many2one('account.account', string='Write-off Account') - @api.depends('invoice_id', 'invoice_id.residual', 'wizard_id.due_date_cutoff', 'invoice_id.partner_id') + @api.depends('invoice_id', 'wizard_id.due_date_cutoff', 'invoice_id.partner_id') def _compute_balances(self): for line in self: residual = line.invoice_id.residual @@ -75,7 +75,9 @@ class AccountRegisterPaymentsInvoiceLine(models.TransientModel): )): amount = abs(move_line.debit - move_line.credit) total_amount += amount - for partial_line in (move_line.matched_debit_ids + move_line.matched_credit_ids): + for partial_line in move_line.matched_debit_ids: + total_reconciled += partial_line.amount + for partial_line in move_line.matched_credit_ids: total_reconciled += partial_line.amount line.residual = residual