From 5d045014547c4702bc912f82a7831850f4a0b9bc Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Wed, 22 Jan 2025 13:46:37 +0530 Subject: [PATCH] fix: Do no query GLs if no PCVs are posted (cherry picked from commit f4d1a5458855d49d0d7626b553d6bf2a21ab6449) --- erpnext/patches/v14_0/update_closing_balances.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/patches/v14_0/update_closing_balances.py b/erpnext/patches/v14_0/update_closing_balances.py index e6544485252..2a081329ce3 100644 --- a/erpnext/patches/v14_0/update_closing_balances.py +++ b/erpnext/patches/v14_0/update_closing_balances.py @@ -18,10 +18,12 @@ def execute(): frappe.db.truncate("Account Closing Balance") pcv_list = get_period_closing_vouchers() - gl_entries = get_gl_entries(pcv_list) - for _, pcvs in itertools.groupby(pcv_list, key=lambda pcv: (pcv.company, pcv.period_start_date)): - process_grouped_pcvs(list(pcvs), gl_entries) + if pcv_list: + gl_entries = get_gl_entries(pcv_list) + + for _, pcvs in itertools.groupby(pcv_list, key=lambda pcv: (pcv.company, pcv.period_start_date)): + process_grouped_pcvs(list(pcvs), gl_entries) def process_grouped_pcvs(pcvs, gl_entries):