From 813b42d706104828a6e2b630289faee365208b1a Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Wed, 17 Jun 2026 19:01:36 +0530 Subject: [PATCH] refactor(postgres): port Cost Center doctype queries to the query builder Co-Authored-By: Claude Opus 4.8 (1M context) --- erpnext/accounts/doctype/cost_center/cost_center.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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):