fix: heatmap not working for customer and supplier (#21578)
Co-authored-by: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com>
Co-authored-by: Nabin Hait <nabinhait@gmail.com>
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index 6e5b33f..528fb4e 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -162,7 +162,7 @@
def set_price_list(party_details, party, party_type, given_price_list, pos=None):
# price list
price_list = get_permitted_documents('Price List')
-
+
# if there is only one permitted document based on user permissions, set it
if price_list and len(price_list) == 1:
price_list = price_list[0]
@@ -465,23 +465,25 @@
from frappe.desk.form.load import get_communication_data
out = {}
- fields = 'date(creation), count(name)'
+ fields = 'creation, count(*)'
after = add_years(None, -1).strftime('%Y-%m-%d')
- group_by='group by date(creation)'
+ group_by='group by Date(creation)'
- data = get_communication_data(doctype, name, after=after, group_by='group by date(creation)',
- fields='date(C.creation) as creation, count(C.name)',as_dict=False)
+ data = get_communication_data(doctype, name, after=after, group_by='group by creation',
+ fields='C.creation as creation, count(C.name)',as_dict=False)
# fetch and append data from Activity Log
data += frappe.db.sql("""select {fields}
from `tabActivity Log`
- where (reference_doctype="{doctype}" and reference_name="{name}")
- or (timeline_doctype in ("{doctype}") and timeline_name="{name}")
- or (reference_doctype in ("Quotation", "Opportunity") and timeline_name="{name}")
+ where (reference_doctype=%(doctype)s and reference_name=%(name)s)
+ or (timeline_doctype in (%(doctype)s) and timeline_name=%(name)s)
+ or (reference_doctype in ("Quotation", "Opportunity") and timeline_name=%(name)s)
and status!='Success' and creation > {after}
{group_by} order by creation desc
- """.format(doctype=frappe.db.escape(doctype), name=frappe.db.escape(name), fields=fields,
- group_by=group_by, after=after), as_dict=False)
+ """.format(fields=fields, group_by=group_by, after=after), {
+ "doctype": doctype,
+ "name": name
+ }, as_dict=False)
timeline_items = dict(data)