From a0003e7f09f7b6021e8ca158e8b5ae06c9b5c10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 31 Oct 2021 10:27:03 +0100 Subject: [PATCH] Use the total amount of the invoice as second currency total issue10923 review381341002 (grafted from 445db5742671487d6179237bf4c7c21c0d1017b6) --HG-- branch : 6.0 --- invoice.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/invoice.py b/invoice.py index 8235fd7c1f..b88ac8ed68 100644 --- a/invoice.py +++ b/invoice.py @@ -985,19 +985,17 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): for tax in self.taxes: move_lines += tax.get_move_lines() - total = Decimal('0.0') - total_currency = Decimal('0.0') - for line in move_lines: - total += line.debit - line.credit - if line.amount_second_currency: - total_currency += line.amount_second_currency - - term_lines = [(self.payment_term_date or today, total)] + total = sum(l.debit - l.credit for l in move_lines) if self.payment_term: payment_date = self.payment_term_date or self.invoice_date term_lines = self.payment_term.compute( total, self.company.currency, payment_date) - remainder_total_currency = total_currency + else: + term_lines = [(self.payment_term_date or today, total)] + if self.currency != self.company.currency: + remainder_total_currency = -self.total_amount + else: + remainder_total_currency = 0 for date, amount in term_lines: if self.type == 'out' and date < today: lang = Lang.get()