[FIX] account: Wrong amount due when reconciling with refund
Steps to reproduce the bug: - Let's consider the following currency rates: 1.00 for USD and 0.50 for EUR - Create invoice I with the same currency of your company (USD) and amount due = 100$ - Validate I - Create refund R with a diffenrent currency of your company (EUR) and amount due = 1€ - Validate R - Reconcile R with I Bug: The amount due of I was 196$ instead of 98$ PS: The root of this issue was coming from function assign_outstanding_credit that was called when reconciling R with I. This function changes the currency_id and the amount_currency of the account move line. So the function _amount_residual defined on model account.move.line was triggered as the currency_id was changed. In _amount_residual, the residual_amount_currency was computed. Forward-port up to saas-11.3 Closes #36252 opw:2062103 closes odoo/odoo#36412 Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
@@ -114,8 +114,10 @@ class AccountInvoice(models.Model):
|
||||
if line.currency_id == self.currency_id:
|
||||
residual += line.amount_residual_currency if line.currency_id else line.amount_residual
|
||||
else:
|
||||
from_currency = (line.currency_id and line.currency_id.with_context(date=line.date)) or line.company_id.currency_id.with_context(date=line.date)
|
||||
residual += from_currency.compute(line.amount_residual, self.currency_id)
|
||||
if line.currency_id:
|
||||
residual += line.currency_id.with_context(date=line.date).compute(line.amount_residual_currency, self.currency_id)
|
||||
else:
|
||||
residual += line.company_id.currency_id.with_context(date=line.date).compute(line.amount_residual, self.currency_id)
|
||||
self.residual_company_signed = abs(residual_company_signed) * sign
|
||||
self.residual_signed = abs(residual) * sign
|
||||
self.residual = abs(residual)
|
||||
|
||||
Reference in New Issue
Block a user