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

If there are still line to invoice or to ship, the sale should not be done.

Closes #12594
This commit is contained in:
Cédric Krier
2023-09-27 12:29:36 +02:00
parent b5ae87d422
commit 7f341ec3ed
3 changed files with 8 additions and 6 deletions
+6 -4
View File
@@ -960,11 +960,13 @@ class Sale(
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 == 'sent'
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, sales):
@@ -68,7 +68,7 @@ Sale with manual invoice method::
>>> sale.click('quote')
>>> sale.click('confirm')
>>> sale.state
'done'
'processing'
>>> sale.invoice_state
'none'
>>> len(sale.invoices)
@@ -56,7 +56,7 @@ Sale with manual shipment method::
>>> sale.click('quote')
>>> sale.click('confirm')
>>> sale.state
'done'
'processing'
>>> len(sale.shipments)
0