From a5739061952eaa42c9e0fd87316933368a0b0148 Mon Sep 17 00:00:00 2001 From: Raimon Esteve Date: Thu, 18 Aug 2022 11:19:04 +0200 Subject: [PATCH] Check hasattr untaxed_amount from invoice create_invoice() not return untaxed_amount (function field) to check is amount is receivable or payable In case has not untaxed_amount, get from on_change_with_amount() --- sale.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sale.py b/sale.py index 7e36409..3c63fab 100644 --- a/sale.py +++ b/sale.py @@ -84,7 +84,12 @@ class Sale(metaclass=PoolMeta): if self.payment_type and self.payment_type.kind == 'both': return self.payment_type - if invoice.untaxed_amount >= ZERO: + if hasattr(invoice, 'untaxed_amount'): + untaxed_amount = invoice.untaxed_amount + else: + untaxed_amount = sum(l.on_change_with_amount() for l in invoice.lines) + + if untaxed_amount >= ZERO: kind = 'receivable' name = 'customer_payment_type' else: