From a7672530f43521ba94609af5aaf35d33ec93e271 Mon Sep 17 00:00:00 2001 From: ravibharathi656 Date: Fri, 24 Oct 2025 14:08:04 +0530 Subject: [PATCH 1/2] fix(gross profit): remove customer name from columns (cherry picked from commit 0009925af01aed0741b86e09391abcfd71c1416c) --- erpnext/accounts/report/gross_profit/gross_profit.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py index 367fe4f4fd2..256e4f959e8 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.py +++ b/erpnext/accounts/report/gross_profit/gross_profit.py @@ -231,6 +231,12 @@ def get_data_when_not_grouped_by_invoice(gross_profit_data, filters, group_wise_ group_columns = group_wise_columns.get(scrub(filters.group_by)) + # removing customer_name from group columns + customer_master_name = frappe.db.get_single_value("Selling Settings", "cust_master_name") + + if "customer_name" in group_columns and customer_master_name == "Customer Name": + group_columns.remove("customer_name") + for src in gross_profit_data.grouped_data: total_base_amount += src.base_amount or 0.00 total_buying_amount += src.buying_amount or 0.00 From 158e1b28a9682a6f5f73d1783f99d6a746b7efa0 Mon Sep 17 00:00:00 2001 From: ravibharathi656 Date: Mon, 27 Oct 2025 17:44:12 +0530 Subject: [PATCH 2/2] fix: avoid group columns mutation (cherry picked from commit 7ce81127d2321519d009bbee3f68bf181cd4cc57) --- erpnext/accounts/report/gross_profit/gross_profit.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py index 256e4f959e8..baf2da6ceea 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.py +++ b/erpnext/accounts/report/gross_profit/gross_profit.py @@ -233,9 +233,12 @@ def get_data_when_not_grouped_by_invoice(gross_profit_data, filters, group_wise_ # removing customer_name from group columns customer_master_name = frappe.db.get_single_value("Selling Settings", "cust_master_name") + supplier_master_name = frappe.db.get_single_value("Buying Settings", "supp_master_name") - if "customer_name" in group_columns and customer_master_name == "Customer Name": - group_columns.remove("customer_name") + if "customer_name" in group_columns and ( + supplier_master_name == "Supplier Name" and customer_master_name == "Customer Name" + ): + group_columns = [col for col in group_columns if col != "customer_name"] for src in gross_profit_data.grouped_data: total_base_amount += src.base_amount or 0.00