Do not consider purchase as done when invoice or shipment state are none

If there are still line to invoice or to receive, the purchase should not be
done.

Closes #12594
This commit is contained in:
Cédric Krier
2023-09-27 12:30:12 +02:00
parent 7f341ec3ed
commit 66e460b97d
2 changed files with 7 additions and 5 deletions
+6 -4
View File
@@ -827,11 +827,13 @@ class Purchase(
def is_done(self):
return ((self.invoice_state == 'paid'
or self.invoice_state == 'none')
or (self.invoice_state == 'none'
and all(not l.quantity
for l in self.lines if l.type == 'line')))
and (self.shipment_state == 'received'
or self.shipment_state == 'none'
or all(l.product.type == 'service'
for l in self.lines if l.product)))
or (self.shipment_state == 'none'
and all(l.product.type == 'service'
for l in self.lines if l.product))))
@classmethod
def delete(cls, purchases):
@@ -68,7 +68,7 @@ Purchase with manual invoice method::
>>> purchase.click('quote')
>>> purchase.click('confirm')
>>> purchase.state
'done'
'processing'
>>> purchase.invoice_state
'none'
>>> len(purchase.invoices)