diff --git a/erpnext/accounts/doctype/cost_center/cost_center.py b/erpnext/accounts/doctype/cost_center/cost_center.py index 761369c80cf..3711f8d5f0c 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.py +++ b/erpnext/accounts/doctype/cost_center/cost_center.py @@ -84,10 +84,10 @@ class CostCenter(NestedSet): return frappe.db.get_value("GL Entry", {"cost_center": self.name}) def check_if_child_exists(self): - return frappe.db.sql( - "select name from `tabCost Center` where \ - parent_cost_center = %s and docstatus != 2", - self.name, + return frappe.get_all( + "Cost Center", + filters={"parent_cost_center": self.name, "docstatus": ["!=", 2]}, + pluck="name", ) def if_allocation_exists_against_cost_center(self):