From eba4f4afe1eac7284518b073f43078b4cb7d7f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Perell=C3=B3=20Rowley?= Date: Mon, 9 Apr 2018 07:48:42 +0200 Subject: [PATCH] Update search.py (#5409) Attending to the comment "In order_by, `idx` gets second priority, because it stores link count" i changed the order in the SQL statement in the order_by variable so the order_by based on meta is before the order_by idx --- frappe/desk/search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/desk/search.py b/frappe/desk/search.py index 8527076afe..3a9fc76ba3 100644 --- a/frappe/desk/search.py +++ b/frappe/desk/search.py @@ -91,7 +91,7 @@ def search_widget(doctype, txt, query=None, searchfield=None, start=0, # In order_by, `idx` gets second priority, because it stores link count from frappe.model.db_query import get_order_by order_by_based_on_meta = get_order_by(doctype, meta) - order_by = "if(_relevance, _relevance, 99999), `tab{0}`.idx desc, {1}".format(doctype, order_by_based_on_meta) + order_by = "if(_relevance, _relevance, 99999), {0}, `tab{1}`.idx desc".format(order_by_based_on_meta, doctype) values = frappe.get_list(doctype, filters=filters, fields=formatted_fields,