fix(crm): keep returning None from create_customer on a linking failure

Preserve the pre-existing contract: create_customer returned None when contact/address linking failed.
The savepoint fix kept the Customer (good) but started returning its name in that case, so a CRM caller
treating a non-None return as full success could skip its retry/error handling. Return None on a linking
failure while still keeping the Customer. (greptile #56683)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Mihir Kandoi
2026-07-01 12:28:36 +05:30
parent 76b31d9269
commit 59b49120b7

View File

@@ -169,6 +169,9 @@ def create_customer(customer_data: dict | None = None):
except Exception:
frappe.db.rollback(save_point="crm_customer_links")
frappe.log_error(frappe.get_traceback(), "Error while linking contacts/address to new Customer")
# keep the Customer, but preserve the pre-existing contract of returning None on a linking failure
# so CRM callers still see the failure signal
return
return customer_name