test: remove sla if no active sla found
diff --git a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py
index d635387..de8f506 100644
--- a/erpnext/support/doctype/service_level_agreement/service_level_agreement.py
+++ b/erpnext/support/doctype/service_level_agreement/service_level_agreement.py
@@ -385,7 +385,7 @@
 	sla = get_active_service_level_agreement_for(doc)
 
 	if not sla:
-		remove_sla_if_applied()
+		remove_sla_if_applied(doc)
 		return
 
 	process_sla(doc, sla)
diff --git a/erpnext/support/doctype/service_level_agreement/test_service_level_agreement.py b/erpnext/support/doctype/service_level_agreement/test_service_level_agreement.py
index b07c862..a34124f 100644
--- a/erpnext/support/doctype/service_level_agreement/test_service_level_agreement.py
+++ b/erpnext/support/doctype/service_level_agreement/test_service_level_agreement.py
@@ -244,6 +244,13 @@
 		applied_sla = frappe.db.get_value('Lead', lead.name, 'service_level_agreement')
 		self.assertEqual(applied_sla, lead_sla.name)
 
+		# check if SLA is removed if condition fails
+		lead.reload()
+		lead.source = None
+		lead.save()
+		applied_sla = frappe.db.get_value('Lead', lead.name, 'service_level_agreement')
+		self.assertFalse(applied_sla)
+
 	def tearDown(self):
 		for d in frappe.get_all("Service Level Agreement"):
 			frappe.delete_doc("Service Level Agreement", d.name, force=1)