fix: Add test to check if SO can be cancelled after linked Maintenance Schedule has been submitted
diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py
index b30bc03..ff25a3a 100644
--- a/erpnext/selling/doctype/sales_order/test_sales_order.py
+++ b/erpnext/selling/doctype/sales_order/test_sales_order.py
@@ -1305,6 +1305,21 @@
so.load_from_db()
self.assertRaises(frappe.LinkExistsError, so.cancel)
+ def test_so_cancellation_after_maintenance_schedule_submission(self):
+ """
+ Expected result: Sales Order should not get cancelled
+ """
+ from erpnext.maintenance.doctype.maintenance_schedule.test_maintenance_schedule import make_maintenance_schedule
+
+ so = make_sales_order()
+ so.submit()
+ ms = make_maintenance_schedule()
+ ms.items[0].sales_order = so.name
+ ms.submit()
+
+ so.load_from_db()
+ self.assertRaises(frappe.LinkExistsError, so.cancel)
+
def test_payment_terms_are_fetched_when_creating_sales_invoice(self):
from erpnext.accounts.doctype.payment_entry.test_payment_entry import (
create_payment_terms_template,