Customer Name is not Unique

SHOW CREATE TABLE tabCustomer;
image


Hi @Manal_Al-Subaei,

When naming customers, if you enter a name that’s already used, It will add a hyphen and a number after the name to differentiate it.

If you’re using the naming series, you’ll need to include a validate method and adjust it accordingly.

I hope this helps.

Thank You!

as you see the screen short in the above
the customer name “test” redundancy without add a hyphen and a number after the name to differentiate it.

which is the applied customer naming?

Auto name
Customer Name
Naming Series

Auto name

So you have to apply the server script using validate or on_update method.

existing_customer = frappe.db.get_value("Customer", {"customer_name": doc.customer_name})
if existing_customer:
    frappe.throw("Customer with the same name already exists. Please choose a different name.")

Output:

Thank You!

i want it in quick entry
not in full validation
and thanks for that code!

It also applies to quick entry and also for the whole form when you create a new customer.

okey thanks