From 358a01a226b914658a2199a236002f2e80006122 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Tue, 10 Sep 2019 19:18:30 +0530 Subject: [PATCH] fix: Quotation Trends report not working for filter group by customer (#18989) --- erpnext/controllers/trends.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/controllers/trends.py b/erpnext/controllers/trends.py index 0404a1e6b0..da44325a9e 100644 --- a/erpnext/controllers/trends.py +++ b/erpnext/controllers/trends.py @@ -54,6 +54,9 @@ def get_data(filters, conditions): if conditions.get('trans') in ['Sales Order', 'Purchase Order']: cond += " and t1.status != 'Closed'" + if conditions.get('trans') == 'Quotation' and filters.get("group_by") == 'Customer': + cond += " and t1.quotation_to = 'Customer'" + year_start_date, year_end_date = frappe.db.get_value("Fiscal Year", filters.get('fiscal_year'), ["year_start_date", "year_end_date"]) @@ -64,7 +67,7 @@ def get_data(filters, conditions): if filters.get("group_by") == 'Item': sel_col = 't2.item_code' elif filters.get("group_by") == 'Customer': - sel_col = 't1.customer' + sel_col = 't1.party_name' if conditions.get('trans') == 'Quotation' else 't1.customer' elif filters.get("group_by") == 'Supplier': sel_col = 't1.supplier' @@ -225,7 +228,7 @@ def based_wise_columns_query(based_on, trans): elif based_on == "Customer": based_on_details["based_on_cols"] = ["Customer:Link/Customer:120", "Territory:Link/Territory:120"] based_on_details["based_on_select"] = "t1.customer_name, t1.territory, " - based_on_details["based_on_group_by"] = 't1.customer' + based_on_details["based_on_group_by"] = 't1.party_name' if trans == 'Quotation' else 't1.customer' based_on_details["addl_tables"] = '' elif based_on == "Customer Group":