[Minor] Added filter condition to Customer Query (#10057)
This commit is contained in:
parent
b5ec8381a6
commit
4b888b95d0
@ -60,6 +60,7 @@ def lead_query(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
|
|
||||||
# searches for customer
|
# searches for customer
|
||||||
def customer_query(doctype, txt, searchfield, start, page_len, filters):
|
def customer_query(doctype, txt, searchfield, start, page_len, filters):
|
||||||
|
conditions = []
|
||||||
cust_master_name = frappe.defaults.get_user_default("cust_master_name")
|
cust_master_name = frappe.defaults.get_user_default("cust_master_name")
|
||||||
|
|
||||||
if cust_master_name == "Customer Name":
|
if cust_master_name == "Customer Name":
|
||||||
@ -79,7 +80,7 @@ def customer_query(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
return frappe.db.sql("""select {fields} from `tabCustomer`
|
return frappe.db.sql("""select {fields} from `tabCustomer`
|
||||||
where docstatus < 2
|
where docstatus < 2
|
||||||
and ({scond}) and disabled=0
|
and ({scond}) and disabled=0
|
||||||
{mcond}
|
{fcond} {mcond}
|
||||||
order by
|
order by
|
||||||
if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999),
|
if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999),
|
||||||
if(locate(%(_txt)s, customer_name), locate(%(_txt)s, customer_name), 99999),
|
if(locate(%(_txt)s, customer_name), locate(%(_txt)s, customer_name), 99999),
|
||||||
@ -88,7 +89,8 @@ def customer_query(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
limit %(start)s, %(page_len)s""".format(**{
|
limit %(start)s, %(page_len)s""".format(**{
|
||||||
"fields": fields,
|
"fields": fields,
|
||||||
"scond": searchfields,
|
"scond": searchfields,
|
||||||
"mcond": get_match_cond(doctype)
|
"mcond": get_match_cond(doctype),
|
||||||
|
"fcond": get_filters_cond(doctype, filters, conditions).replace('%', '%%'),
|
||||||
}), {
|
}), {
|
||||||
'txt': "%%%s%%" % txt,
|
'txt': "%%%s%%" % txt,
|
||||||
'_txt': txt.replace("%", ""),
|
'_txt': txt.replace("%", ""),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user