From 71642c6127c36fcd4dd609e2df39899e2a9f89d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 17 Sep 2018 17:51:05 +0200 Subject: [PATCH] Compare amount in invoice currency against amount_to_pay The transition_pay should have the same test as the default_ask because amount_to_pay is computed in the invoice currency. Otherwise if the rate is lower the test fail in transition_pay and the empty ask state is tested which raises an exception. issue7192 review52471002 --- invoice.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/invoice.py b/invoice.py index ebf43f9184..796021895a 100644 --- a/invoice.py +++ b/invoice.py @@ -2680,6 +2680,8 @@ class PayInvoice(Wizard): with Transaction().set_context(date=self.start.date): amount = Currency.compute(self.start.currency, self.start.amount, invoice.company.currency) + amount_invoice = Currency.compute( + self.start.currency, self.start.amount, invoice.currency) reconcile_lines, remainder = \ self.get_reconcile_lines_for_amount(invoice, amount) @@ -2690,7 +2692,7 @@ class PayInvoice(Wizard): amount_second_currency = self.start.amount second_currency = self.start.currency - if (abs(amount) > abs(invoice.amount_to_pay) + if (amount_invoice > invoice.amount_to_pay and self.ask.type != 'writeoff'): self.raise_user_error('amount_greater_amount_to_pay', (invoice.rec_name,))