[fix] Customer de-duplication sql
This commit is contained in:
parent
9e425863a1
commit
ddad05dab3
@ -29,14 +29,14 @@ class Customer(TransactionBase):
|
|||||||
frappe.throw(_("Series is mandatory"), frappe.MandatoryError)
|
frappe.throw(_("Series is mandatory"), frappe.MandatoryError)
|
||||||
|
|
||||||
self.name = make_autoname(self.naming_series+'.#####')
|
self.name = make_autoname(self.naming_series+'.#####')
|
||||||
|
|
||||||
def get_customer_name(self):
|
def get_customer_name(self):
|
||||||
if frappe.db.get_value("Customer", self.customer_name):
|
if frappe.db.get_value("Customer", self.customer_name):
|
||||||
count = frappe.db.sql("""select ifnull(max(SUBSTRING_INDEX(name, ' ', -1)), 0) from tabCustomer
|
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
|
count = cint(count) + 1
|
||||||
return "{0} - {1}".format(self.customer_name, cstr(count))
|
return "{0} - {1}".format(self.customer_name, cstr(count))
|
||||||
|
|
||||||
return self.customer_name
|
return self.customer_name
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
@ -234,4 +234,4 @@ def get_credit_limit(customer, company):
|
|||||||
credit_limit = frappe.db.get_value("Customer Group", customer_group, "credit_limit") or \
|
credit_limit = frappe.db.get_value("Customer Group", customer_group, "credit_limit") or \
|
||||||
frappe.db.get_value("Company", company, "credit_limit")
|
frappe.db.get_value("Company", company, "credit_limit")
|
||||||
|
|
||||||
return credit_limit
|
return credit_limit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user