diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py index eaaa2eb9748..49f921d9865 100644 --- a/erpnext/selling/doctype/quotation/test_quotation.py +++ b/erpnext/selling/doctype/quotation/test_quotation.py @@ -1001,6 +1001,31 @@ class TestQuotation(IntegrationTestCase): so1.submit() self.assertRaises(frappe.ValidationError, so2.submit) + def test_quotation_status(self): + quotation = make_quotation() + + so1 = make_sales_order(quotation.name) + so1.delivery_date = nowdate() + so1.submit() + quotation.reload() + self.assertEqual(quotation.status, "Ordered") + so1.cancel() + + quotation.reload() + self.assertEqual(quotation.status, "Open") + + so2 = make_sales_order(quotation.name) + so2.delivery_date = nowdate() + so2.items[0].qty = 1 + so2.submit() + quotation.reload() + self.assertEqual(quotation.status, "Partially Ordered") + + so2.cancel() + + quotation.reload() + self.assertEqual(quotation.status, "Open") + def enable_calculate_bundle_price(enable=1): selling_settings = frappe.get_doc("Selling Settings") diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 876b11459b4..9d39c38505d 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -530,7 +530,7 @@ class SalesOrder(SellingController): "Unreconcile Payment Entries", ) super().on_cancel() - + super().update_prevdoc_status() # Cannot cancel closed SO if self.status == "Closed": frappe.throw(_("Closed order cannot be cancelled. Unclose to cancel."))