From cee2e62b6f2732a4f4560951218d0672ff67bdb5 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 16 Dec 2016 14:59:02 +0100 Subject: [PATCH] [FIX] account: add comment for the previous revision It has been done outside of the previous commit to give the possibility to point the comment to the according revision, as this is a really tricky case. opw-687201 --- addons/account/models/account_payment.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 454cb4ad5f9..486c7eba0ab 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -385,6 +385,9 @@ class account_payment(models.Model): if self.payment_difference_handling == 'reconcile' and self.payment_difference: writeoff_line = self._get_shared_move_line_vals(0, 0, 0, move.id, False) 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:] + # the writeoff debit and credit must be computed from the invoice residual in company currency + # minus the payment amount in company currency, and not from the payment difference in the payment currency + # to avoid loss of precision during the currency rate computations. See revision 20935462a0cabeb45480ce70114ff2f4e91eaf79 for a detailed example. 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