[enhancement] sort links on basis of link_count (idx)
This commit is contained in:
parent
22ef68945d
commit
3574b37ff3
@ -40,6 +40,7 @@ def employee_query(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
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, employee_name), locate(%(_txt)s, employee_name), 99999),
|
if(locate(%(_txt)s, employee_name), locate(%(_txt)s, employee_name), 99999),
|
||||||
|
idx desc,
|
||||||
name, employee_name
|
name, employee_name
|
||||||
limit %(start)s, %(page_len)s""".format(**{
|
limit %(start)s, %(page_len)s""".format(**{
|
||||||
'key': searchfield,
|
'key': searchfield,
|
||||||
@ -64,6 +65,7 @@ def lead_query(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999),
|
if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999),
|
||||||
if(locate(%(_txt)s, lead_name), locate(%(_txt)s, lead_name), 99999),
|
if(locate(%(_txt)s, lead_name), locate(%(_txt)s, lead_name), 99999),
|
||||||
if(locate(%(_txt)s, company_name), locate(%(_txt)s, company_name), 99999),
|
if(locate(%(_txt)s, company_name), locate(%(_txt)s, company_name), 99999),
|
||||||
|
idx desc,
|
||||||
name, lead_name
|
name, lead_name
|
||||||
limit %(start)s, %(page_len)s""".format(**{
|
limit %(start)s, %(page_len)s""".format(**{
|
||||||
'key': searchfield,
|
'key': searchfield,
|
||||||
@ -94,6 +96,7 @@ def customer_query(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
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),
|
||||||
|
idx desc,
|
||||||
name, customer_name
|
name, customer_name
|
||||||
limit %(start)s, %(page_len)s""".format(**{
|
limit %(start)s, %(page_len)s""".format(**{
|
||||||
"fields": fields,
|
"fields": fields,
|
||||||
@ -123,6 +126,7 @@ def supplier_query(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
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, supplier_name), locate(%(_txt)s, supplier_name), 99999),
|
if(locate(%(_txt)s, supplier_name), locate(%(_txt)s, supplier_name), 99999),
|
||||||
|
idx desc,
|
||||||
name, supplier_name
|
name, supplier_name
|
||||||
limit %(start)s, %(page_len)s """.format(**{
|
limit %(start)s, %(page_len)s """.format(**{
|
||||||
'field': fields,
|
'field': fields,
|
||||||
@ -142,6 +146,7 @@ def tax_account_query(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
and is_group = 0
|
and is_group = 0
|
||||||
and company = %s
|
and company = %s
|
||||||
and `%s` LIKE %s
|
and `%s` LIKE %s
|
||||||
|
order by idx desc, name
|
||||||
limit %s, %s""" %
|
limit %s, %s""" %
|
||||||
(", ".join(['%s']*len(filters.get("account_type"))), "%s", searchfield, "%s", "%s", "%s"),
|
(", ".join(['%s']*len(filters.get("account_type"))), "%s", searchfield, "%s", "%s", "%s"),
|
||||||
tuple(filters.get("account_type") + [filters.get("company"), "%%%s%%" % txt,
|
tuple(filters.get("account_type") + [filters.get("company"), "%%%s%%" % txt,
|
||||||
@ -176,6 +181,7 @@ def item_query(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
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, item_name), locate(%(_txt)s, item_name), 99999),
|
if(locate(%(_txt)s, item_name), locate(%(_txt)s, item_name), 99999),
|
||||||
|
idx desc,
|
||||||
name, item_name
|
name, item_name
|
||||||
limit %(start)s, %(page_len)s """.format(key=searchfield,
|
limit %(start)s, %(page_len)s """.format(key=searchfield,
|
||||||
fcond=get_filters_cond(doctype, filters, conditions),
|
fcond=get_filters_cond(doctype, filters, conditions),
|
||||||
@ -197,9 +203,16 @@ def bom(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
and tabBOM.is_active=1
|
and tabBOM.is_active=1
|
||||||
and tabBOM.%(key)s like "%(txt)s"
|
and tabBOM.%(key)s like "%(txt)s"
|
||||||
%(fcond)s %(mcond)s
|
%(fcond)s %(mcond)s
|
||||||
limit %(start)s, %(page_len)s """ % {'key': searchfield, 'txt': "%%%s%%" % frappe.db.escape(txt),
|
order_by
|
||||||
|
if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999),
|
||||||
|
idx desc, name
|
||||||
|
limit %(start)s, %(page_len)s """ % {
|
||||||
|
'key': searchfield,
|
||||||
|
'txt': "%%%s%%" % frappe.db.escape(txt),
|
||||||
|
'_txt': txt.replace("%", ""),
|
||||||
'fcond': get_filters_cond(doctype, filters, conditions),
|
'fcond': get_filters_cond(doctype, filters, conditions),
|
||||||
'mcond':get_match_cond(doctype), 'start': start, 'page_len': page_len})
|
'mcond':get_match_cond(doctype), 'start': start, 'page_len': page_len
|
||||||
|
})
|
||||||
|
|
||||||
def get_project_name(doctype, txt, searchfield, start, page_len, filters):
|
def get_project_name(doctype, txt, searchfield, start, page_len, filters):
|
||||||
cond = ''
|
cond = ''
|
||||||
@ -208,10 +221,19 @@ def get_project_name(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
|
|
||||||
return frappe.db.sql("""select `tabProject`.name from `tabProject`
|
return frappe.db.sql("""select `tabProject`.name from `tabProject`
|
||||||
where `tabProject`.status not in ("Completed", "Cancelled")
|
where `tabProject`.status not in ("Completed", "Cancelled")
|
||||||
and {cond} `tabProject`.name like %s {match_cond}
|
and {cond} `tabProject`.name like %(txt)s {match_cond}
|
||||||
order by `tabProject`.name asc
|
order by
|
||||||
limit {start}, {page_len}""".format(cond=cond, match_cond=get_match_cond(doctype),
|
if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999),
|
||||||
start=start, page_len=page_len), "%{0}%".format(txt))
|
idx desc,
|
||||||
|
`tabProject`.name asc
|
||||||
|
limit {start}, {page_len}""".format(
|
||||||
|
cond=cond,
|
||||||
|
match_cond=get_match_cond(doctype),
|
||||||
|
start=start,
|
||||||
|
page_len=page_len), {
|
||||||
|
"txt": "%{0}%".format(txt),
|
||||||
|
"_txt": txt.relace('%', '')
|
||||||
|
})
|
||||||
|
|
||||||
def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len, filters):
|
def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len, filters):
|
||||||
return frappe.db.sql("""select `tabDelivery Note`.name, `tabDelivery Note`.customer_name
|
return frappe.db.sql("""select `tabDelivery Note`.name, `tabDelivery Note`.customer_name
|
||||||
@ -310,7 +332,8 @@ def get_income_account(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
or tabAccount.account_type in ("Income Account", "Temporary"))
|
or tabAccount.account_type in ("Income Account", "Temporary"))
|
||||||
and tabAccount.is_group=0
|
and tabAccount.is_group=0
|
||||||
and tabAccount.`{key}` LIKE %(txt)s
|
and tabAccount.`{key}` LIKE %(txt)s
|
||||||
{condition} {match_condition}"""
|
{condition} {match_condition}
|
||||||
|
order by idx desc, name"""
|
||||||
.format(condition=condition, match_condition=get_match_cond(doctype), key=searchfield), {
|
.format(condition=condition, match_condition=get_match_cond(doctype), key=searchfield), {
|
||||||
'txt': "%%%s%%" % frappe.db.escape(txt),
|
'txt': "%%%s%%" % frappe.db.escape(txt),
|
||||||
'company': filters.get("company", "")
|
'company': filters.get("company", "")
|
||||||
|
@ -31,7 +31,7 @@ def get_product_list(search=None, start=0, limit=12):
|
|||||||
search = "%" + cstr(search) + "%"
|
search = "%" + cstr(search) + "%"
|
||||||
|
|
||||||
# order by
|
# order by
|
||||||
query += """ order by weightage desc, modified desc limit %s, %s""" % (start, limit)
|
query += """ order by weightage desc, idx desc, modified desc limit %s, %s""" % (start, limit)
|
||||||
|
|
||||||
data = frappe.db.sql(query, {
|
data = frappe.db.sql(query, {
|
||||||
"search": search,
|
"search": search,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user