diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 7320c2c795b..454cb4ad5f9 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -384,7 +384,12 @@ class account_payment(models.Model): #Reconcile with the invoices if self.payment_difference_handling == 'reconcile' and self.payment_difference: writeoff_line = self._get_shared_move_line_vals(0, 0, 0, move.id, False) - debit_wo, credit_wo, amount_currency_wo, currency_id = aml_obj.with_context(date=self.payment_date).compute_amount_fields(self.payment_difference, self.currency_id, self.company_id.currency_id, invoice_currency) + amount_currency_wo, currency_id = aml_obj.with_context(date=self.payment_date).compute_amount_fields(self.payment_difference, self.currency_id, self.company_id.currency_id, invoice_currency)[2:] + total_residual_company_signed = sum(invoice.residual_company_signed for invoice in self.invoice_ids) + total_payment_company_signed = self.currency_id.with_context(date=self.payment_date).compute(self.amount, self.company_id.currency_id) + amount_wo = total_residual_company_signed - total_payment_company_signed + debit_wo = amount_wo > 0 and amount_wo or 0.0 + credit_wo = amount_wo < 0 and -amount_wo or 0.0 writeoff_line['name'] = _('Counterpart') writeoff_line['account_id'] = self.writeoff_account_id.id writeoff_line['debit'] = debit_wo