mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-14 23:18:40 +00:00
fix(telephony): scope link_existing_conversations rollback to a savepoint (review)
link_existing_conversations is the Contact after_insert hook; a full frappe.db.rollback() on a failed call_log.save() would discard the triggering Contact insert itself (and, in test mode, the whole unit of work). Savepoint the hook's DB work and roll back only to it.
This commit is contained in:
@@ -163,6 +163,7 @@ def link_existing_conversations(doc, state):
|
||||
return
|
||||
if doc.doctype != "Contact":
|
||||
return
|
||||
frappe.db.savepoint("link_call_logs")
|
||||
try:
|
||||
numbers = [d.phone for d in doc.phone_nos]
|
||||
|
||||
@@ -196,7 +197,7 @@ def link_existing_conversations(doc, state):
|
||||
if not frappe.in_test:
|
||||
frappe.db.commit()
|
||||
except Exception:
|
||||
frappe.db.rollback()
|
||||
frappe.db.rollback(save_point="link_call_logs")
|
||||
frappe.log_error(title=_("Error during caller information update"))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user