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>
This commit is contained in:
rohitwaghchaure 2020-05-05 12:12:33 +05:30 committed by GitHub
parent 8e08698c15
commit 5210761e57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -162,7 +162,7 @@ def get_default_price_list(party):
def set_price_list(party_details, party, party_type, given_price_list, pos=None): def set_price_list(party_details, party, party_type, given_price_list, pos=None):
# price list # price list
price_list = get_permitted_documents('Price List') price_list = get_permitted_documents('Price List')
# if there is only one permitted document based on user permissions, set it # if there is only one permitted document based on user permissions, set it
if price_list and len(price_list) == 1: if price_list and len(price_list) == 1:
price_list = price_list[0] price_list = price_list[0]
@ -465,23 +465,25 @@ def get_timeline_data(doctype, name):
from frappe.desk.form.load import get_communication_data from frappe.desk.form.load import get_communication_data
out = {} out = {}
fields = 'date(creation), count(name)' fields = 'creation, count(*)'
after = add_years(None, -1).strftime('%Y-%m-%d') 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)', data = get_communication_data(doctype, name, after=after, group_by='group by creation',
fields='date(C.creation) as creation, count(C.name)',as_dict=False) fields='C.creation as creation, count(C.name)',as_dict=False)
# fetch and append data from Activity Log # fetch and append data from Activity Log
data += frappe.db.sql("""select {fields} data += frappe.db.sql("""select {fields}
from `tabActivity Log` from `tabActivity Log`
where (reference_doctype="{doctype}" and reference_name="{name}") where (reference_doctype=%(doctype)s and reference_name=%(name)s)
or (timeline_doctype in ("{doctype}") and timeline_name="{name}") or (timeline_doctype in (%(doctype)s) and timeline_name=%(name)s)
or (reference_doctype in ("Quotation", "Opportunity") and timeline_name="{name}") or (reference_doctype in ("Quotation", "Opportunity") and timeline_name=%(name)s)
and status!='Success' and creation > {after} and status!='Success' and creation > {after}
{group_by} order by creation desc {group_by} order by creation desc
""".format(doctype=frappe.db.escape(doctype), name=frappe.db.escape(name), fields=fields, """.format(fields=fields, group_by=group_by, after=after), {
group_by=group_by, after=after), as_dict=False) "doctype": doctype,
"name": name
}, as_dict=False)
timeline_items = dict(data) timeline_items = dict(data)