From 66e460b97db44fde6efa37d6ec753d1a0cd23cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 27 Sep 2023 12:30:12 +0200 Subject: [PATCH] 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 --- modules/purchase/purchase.py | 10 ++++++---- .../tests/scenario_purchase_manual_invoice.rst | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/purchase/purchase.py b/modules/purchase/purchase.py index c00b5ab8b5..602f58d951 100644 --- a/modules/purchase/purchase.py +++ b/modules/purchase/purchase.py @@ -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): diff --git a/modules/purchase/tests/scenario_purchase_manual_invoice.rst b/modules/purchase/tests/scenario_purchase_manual_invoice.rst index 168840b693..de1b1be9b9 100644 --- a/modules/purchase/tests/scenario_purchase_manual_invoice.rst +++ b/modules/purchase/tests/scenario_purchase_manual_invoice.rst @@ -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)