refactor(stock): use get_all for warehouse subtree in capacity dashboard

Replace the raw lft/rgt SELECT with frappe.get_all(pluck="name"). Same result
on MariaDB; valid under Postgres.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mihir Kandoi
2026-06-19 22:11:05 +05:30
parent 497a0abb07
commit f03a81b943

View File

@@ -40,12 +40,8 @@ def get_filters(item_code=None, warehouse=None, parent_warehouse=None, company=N
filters.append(["company", "=", company])
if parent_warehouse:
lft, rgt = frappe.db.get_value("Warehouse", parent_warehouse, ["lft", "rgt"])
warehouses = frappe.db.sql_list(
"""
select name from `tabWarehouse`
where lft >=%s and rgt<=%s
""",
(lft, rgt),
warehouses = frappe.get_all(
"Warehouse", filters={"lft": [">=", lft], "rgt": ["<=", rgt]}, pluck="name"
)
filters.append(["warehouse", "in", warehouses])
return filters