From a4928f6f5b9845a3db92dd7db7081f30775845fd Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Thu, 6 Feb 2020 12:50:25 +0530 Subject: [PATCH] fix: Add report link in module view and fix date filter --- erpnext/config/crm.py | 7 +++++++ .../report/territory_wise_sales/territory_wise_sales.py | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/erpnext/config/crm.py b/erpnext/config/crm.py index cf1021948a5..09c2a65633b 100644 --- a/erpnext/config/crm.py +++ b/erpnext/config/crm.py @@ -117,6 +117,13 @@ def get_data(): "name": "Lead Owner Efficiency", "doctype": "Lead", "dependencies": ["Lead"] + }, + { + "type": "report", + "is_query_report": True, + "name": "Territory-wise Sales", + "doctype": "Opportunity", + "dependencies": ["Opportunity"] } ] }, diff --git a/erpnext/selling/report/territory_wise_sales/territory_wise_sales.py b/erpnext/selling/report/territory_wise_sales/territory_wise_sales.py index 415d078b718..656ff33ab61 100644 --- a/erpnext/selling/report/territory_wise_sales/territory_wise_sales.py +++ b/erpnext/selling/report/territory_wise_sales/territory_wise_sales.py @@ -94,8 +94,10 @@ def get_data(filters=None): def get_opportunities(filters): conditions = "" - if filters.from_date and filters.to_date: - conditions = " WHERE transaction_date between %(from_date)s and %(to_date)s" + if filters.get('transaction_date'): + conditions = " WHERE transaction_date between {0} and {1}".format( + frappe.db.escape(filters['transaction_date'][0]), + frappe.db.escape(filters['transaction_date'][1])) if filters.company: if conditions: @@ -108,7 +110,7 @@ def get_opportunities(filters): return frappe.db.sql(""" SELECT name, territory, opportunity_amount FROM `tabOpportunity` {0} - """.format(conditions), filters, as_dict=1) #nosec + """.format(conditions), filters, as_dict=1, debug=1) #nosec def get_quotations(opportunities): if not opportunities: