Skip to content

Commit

Permalink
fix: prevent unnecessary db.commit
Browse files Browse the repository at this point in the history
  • Loading branch information
HarryPaulo committed Jan 16, 2025
1 parent dcf0860 commit 5f15b0b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions erpnext/telephony/doctype/call_log/call_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"))

Expand Down

0 comments on commit 5f15b0b

Please sign in to comment.