From 0e54e532ffd2339c3916d4f7ea2de0774316b2b8 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Fri, 26 Jun 2026 10:44:05 +0530 Subject: [PATCH] refactor(accounts): use frappe.get_all for trial balance account fetch The Account metadata fetch in the DuckDB trial-balance path is a plain static SELECT (fixed columns, single company filter, order by lft). Convert it to frappe.get_all. Verified on Postgres: identical 98 rows, same order and same dict payload as the raw query. --- .../report/trial_balance/trial_balance.py | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/report/trial_balance/trial_balance.py b/erpnext/accounts/report/trial_balance/trial_balance.py index 85a5142b777..d8fce97263e 100644 --- a/erpnext/accounts/report/trial_balance/trial_balance.py +++ b/erpnext/accounts/report/trial_balance/trial_balance.py @@ -597,11 +597,21 @@ def execute_synced_report(filters): def get_data_duckdb(filters, conn): # accounts and all metadata via frappe.db — only GL Entry comes from DuckDB - accounts = frappe.db.sql( - """select name, account_number, parent_account, account_name, root_type, report_type, is_group, lft, rgt - from `tabAccount` where company=%s order by lft""", - filters.company, - as_dict=True, + accounts = frappe.get_all( + "Account", + filters={"company": filters.company}, + fields=[ + "name", + "account_number", + "parent_account", + "account_name", + "root_type", + "report_type", + "is_group", + "lft", + "rgt", + ], + order_by="lft", ) if not accounts: return None