From 37be306b751b0bc268e897bfbe3e46903bcf0232 Mon Sep 17 00:00:00 2001 From: Raimon Esteve Date: Thu, 26 Oct 2023 14:26:25 +0200 Subject: [PATCH] In case total_amount is < 0, the condition is absolute value (abs) #162987 --- sale.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sale.py b/sale.py index e0b4160..d0d1275 100644 --- a/sale.py +++ b/sale.py @@ -176,12 +176,14 @@ class Sale(metaclass=PoolMeta): @fields.depends('state', 'invoice_state', 'lines', 'total_amount', 'paid_amount') def on_change_with_allow_to_pay(self, name=None): + # in case total_amount is < 0, the condition is absolute value (abs) if (self.state in ('cancelled', 'done') or (self.invoice_state == 'paid') or not self.lines or (self.total_amount is not None and self.paid_amount is not None - and (self.total_amount <= self.paid_amount))): + and self.total_amount != 0. + and (abs(self.total_amount) <= abs(self.paid_amount)))): return False return True