From 5f15b0b65b1950589d9e4e3b16e1d950cb67b459 Mon Sep 17 00:00:00 2001 From: HarryPaulo Date: Thu, 16 Jan 2025 17:40:54 -0300 Subject: [PATCH] fix: prevent unnecessary db.commit --- erpnext/telephony/doctype/call_log/call_log.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/erpnext/telephony/doctype/call_log/call_log.py b/erpnext/telephony/doctype/call_log/call_log.py index 7afa06ff9a7..8093a6a0226 100644 --- a/erpnext/telephony/doctype/call_log/call_log.py +++ b/erpnext/telephony/doctype/call_log/call_log.py @@ -157,6 +157,8 @@ def link_existing_conversations(doc, state): """ Called from hooks on creation of Contact or Lead to link all the existing conversations. """ + if doc.flags.ignore_auto_link_call_log: + return if doc.doctype != "Contact": return try: @@ -183,12 +185,12 @@ def link_existing_conversations(doc, state): """, dict(phone_number=f"%{number}", docname=doc.name, doctype=doc.doctype), ) - - for log in logs: - call_log = frappe.get_doc("Call Log", log) - call_log.add_link(link_type=doc.doctype, link_name=doc.name) - call_log.save(ignore_permissions=True) - frappe.db.commit() + if logs: + for log in logs: + call_log = frappe.get_doc("Call Log", log) + call_log.add_link(link_type=doc.doctype, link_name=doc.name) + call_log.save(ignore_permissions=True) + frappe.db.commit() except Exception: frappe.log_error(title=_("Error during caller information update"))