[fix] Customer de-duplication sql

This commit is contained in:
Anand Doshi 2015-11-20 17:29:22 +05:30
parent 9e425863a1
commit ddad05dab3

View File

@ -33,7 +33,7 @@ class Customer(TransactionBase):
def get_customer_name(self):
if frappe.db.get_value("Customer", self.customer_name):
count = frappe.db.sql("""select ifnull(max(SUBSTRING_INDEX(name, ' ', -1)), 0) from tabCustomer
where name like '%{0} - %'""".format(self.customer_name), as_list=1)[0][0]
where name like %s""", "%{0} - %".format(self.customer_name), as_list=1)[0][0]
count = cint(count) + 1
return "{0} - {1}".format(self.customer_name, cstr(count))