diff --git a/erpnext/crm/doctype/utils.py b/erpnext/crm/doctype/utils.py index cacc5a16607..f3230e36568 100644 --- a/erpnext/crm/doctype/utils.py +++ b/erpnext/crm/doctype/utils.py @@ -1,53 +1,6 @@ import frappe -@frappe.whitelist() -def get_last_interaction(contact=None, lead=None): - if not contact and not lead: - return - - last_communication = None - last_issue = None - if contact: - query_condition = "" - values = [] - contact = frappe.get_doc("Contact", contact) - for link in contact.links: - if link.link_doctype == "Customer": - last_issue = get_last_issue_from_customer(link.link_name) - query_condition += "(`reference_doctype`=%s AND `reference_name`=%s) OR" - values += [link.link_doctype, link.link_name] - - if query_condition: - # remove extra appended 'OR' - query_condition = query_condition[:-2] - last_communication = frappe.db.sql( - f""" - SELECT `name`, `content` - FROM `tabCommunication` - WHERE `sent_or_received`='Received' - AND ({query_condition}) - ORDER BY `modified` - LIMIT 1 - """, - values, - as_dict=1, - ) # nosec - - if lead: - last_communication = frappe.get_all( - "Communication", - filters={"reference_doctype": "Lead", "reference_name": lead, "sent_or_received": "Received"}, - fields=["name", "content"], - order_by="`creation` DESC", - limit=1, - ) - - last_communication = last_communication[0] if last_communication else None - - return {"last_communication": last_communication, "last_issue": last_issue} - - def get_last_issue_from_customer(customer_name): issues = frappe.get_all( "Issue",