From 0c625ff69ba9b8c623e9b8feaa61ad25dc8d3b37 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sun, 16 Aug 2026 14:21:44 +0000 Subject: [PATCH] fix(crm)!: remove unused `get_last_interaction` endpoint (backport #58214) (#58215) Co-authored-by: Diptanil Saha --- erpnext/crm/doctype/utils.py | 47 ------------------------------------ 1 file changed, 47 deletions(-) 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",