From 5d56a04a846f56a2255dda0709333498b62d1123 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sun, 5 Jul 2026 15:10:32 +0530 Subject: [PATCH] fix(controllers): guard empty group-by detail row in trends With an explicit GROUP BY, a zero-match detail query returns no rows (the old bare aggregate returned one all-NULL row), so row1[0][0] would raise IndexError. Skip the entry instead. --- erpnext/controllers/trends.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/controllers/trends.py b/erpnext/controllers/trends.py index 3ece6c5a820..530b6574a42 100644 --- a/erpnext/controllers/trends.py +++ b/erpnext/controllers/trends.py @@ -203,6 +203,9 @@ def get_data(filters, conditions): as_list=1, ) + if not row1: + continue + des[ind] = row[i][0] des[ind - 1] = row1[0][0]