Restricting customer creation to 1 from a lead

Currently, system is allowing creation of multiple customer from a single lead. The same needs to be restricted to one.

I have written the script in python using frappe but not working.

You can set the validate in the customer doctype.

Please apply the server script in the server script doctype.

if doc.lead_name:
    existing_customer = frappe.db.get_value("Customer", {"lead_name": doc.lead_name}, "name")
    
    if existing_customer and existing_customer != doc.name:
        frappe.throw(f"A customer named '{existing_customer}' has already been created from the lead: {doc.lead_name}")

Output:

1 Like

Thanks a lot!!!