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.
This commit is contained in:
Jared Kipe
2018-07-10 16:20:13 -07:00
parent a1e46a3d74
commit 086c85200f

View File

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