From e7d277d51e0d7485ae66b1c8980391fa151ec8a8 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Tue, 16 Jul 2019 13:53:41 +0530 Subject: [PATCH] fix: Last communication query --- erpnext/communication/doctype/call_log/call_log.json | 7 +------ erpnext/crm/doctype/utils.py | 8 ++++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/erpnext/communication/doctype/call_log/call_log.json b/erpnext/communication/doctype/call_log/call_log.json index 43da3b3f85..508ade9764 100644 --- a/erpnext/communication/doctype/call_log/call_log.json +++ b/erpnext/communication/doctype/call_log/call_log.json @@ -145,13 +145,8 @@ "write": 1 }, { - "email": 1, - "export": 1, - "print": 1, "read": 1, - "report": 1, - "role": "Employee", - "share": 1 + "role": "Employee" } ], "sort_field": "modified", diff --git a/erpnext/crm/doctype/utils.py b/erpnext/crm/doctype/utils.py index 0cd2557cc8..7e9a8f4688 100644 --- a/erpnext/crm/doctype/utils.py +++ b/erpnext/crm/doctype/utils.py @@ -20,7 +20,7 @@ def get_last_interaction(contact=None, lead=None): if query_condition: # remove extra appended 'OR' query_condition = query_condition[:-2] - communication = frappe.db.sql(""" + last_communication = frappe.db.sql(""" SELECT `name`, `content` FROM `tabCommunication` WHERE @@ -28,12 +28,12 @@ def get_last_interaction(contact=None, lead=None): ({}) ORDER BY `modified` LIMIT 1 - """.format(query_condition)) # nosec + """.format(query_condition), as_dict=1) # nosec if lead: last_communication = frappe.get_all('Communication', filters={ - 'reference_doctype': reference_doc.doctype, - 'reference_name': reference_doc.name, + 'reference_doctype': 'Contact', + 'reference_name': contact, 'sent_or_received': 'Received' }, fields=['name', 'content'], limit=1)