1
0
Fork 0

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()
This commit is contained in:
Raimon Esteve 2022-08-18 11:19:04 +02:00
parent 5b0fbd7685
commit a573906195
1 changed files with 6 additions and 1 deletions

View File

@ -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: