From 460bb9e5d0563444f49f143b720bae8034d60ebd Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Tue, 30 Jun 2026 13:01:32 +0530 Subject: [PATCH] fix(crm): scope create_address rollback to a savepoint (review) create_address is a helper called by create_prospect/create_customer AFTER they insert the Prospect/Customer. Its full frappe.db.rollback() on an address-save failure rolled back the caller's just-inserted parent doc, then swallowed the exception, so the caller returned a Prospect/Customer name that no longer existed. Scope the rollback to savepoint('crm_create_address') so only the address work is undone; the parent doc survives and the failed address is just logged. --- erpnext/crm/frappe_crm_api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/crm/frappe_crm_api.py b/erpnext/crm/frappe_crm_api.py index 9b1b77755a8..a13109181a1 100644 --- a/erpnext/crm/frappe_crm_api.py +++ b/erpnext/crm/frappe_crm_api.py @@ -71,6 +71,7 @@ def create_address(doctype, docname, address): if not address: return address = frappe.parse_json(address) + frappe.db.savepoint("crm_create_address") try: _address = frappe.db.exists("Address", address.get("name")) if not _address: @@ -98,7 +99,7 @@ def create_address(doctype, docname, address): address.save(ignore_permissions=True) return address.name except Exception: - frappe.db.rollback() + frappe.db.rollback(save_point="crm_create_address") frappe.log_error(frappe.get_traceback(), f"Error while creating address for {docname}")