From 7f341ec3edc61cd6dcecbb321dc9fde950c4bbdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 27 Sep 2023 12:29:36 +0200 Subject: [PATCH] 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 --- modules/sale/sale.py | 10 ++++++---- modules/sale/tests/scenario_sale_manual_invoice.rst | 2 +- modules/sale/tests/scenario_sale_manual_shipment.rst | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/sale/sale.py b/modules/sale/sale.py index 193ccbafc1..606a610217 100644 --- a/modules/sale/sale.py +++ b/modules/sale/sale.py @@ -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): diff --git a/modules/sale/tests/scenario_sale_manual_invoice.rst b/modules/sale/tests/scenario_sale_manual_invoice.rst index 71f9a2c5f3..bfc427a99f 100644 --- a/modules/sale/tests/scenario_sale_manual_invoice.rst +++ b/modules/sale/tests/scenario_sale_manual_invoice.rst @@ -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) diff --git a/modules/sale/tests/scenario_sale_manual_shipment.rst b/modules/sale/tests/scenario_sale_manual_shipment.rst index fa11e52511..597d4b89db 100644 --- a/modules/sale/tests/scenario_sale_manual_shipment.rst +++ b/modules/sale/tests/scenario_sale_manual_shipment.rst @@ -56,7 +56,7 @@ Sale with manual shipment method:: >>> sale.click('quote') >>> sale.click('confirm') >>> sale.state - 'done' + 'processing' >>> len(sale.shipments) 0