Minor fix

This commit is contained in:
Nabin Hait 2014-11-12 17:27:40 +05:30
parent 1f994d31b8
commit 3e18bfded9

View file

@ -317,13 +317,14 @@ class DatabaseQuery(object):
) and not self.group_by)
if not group_function_without_group_by:
args.order_by = "`tab{0}`.`{1}` {2}".format(self.doctype,
meta.sort_field or "modified", meta.sort_order or "desc")
if args.get("sort_field") and args.get("sort_order"):
args.order_by = "`tab{0}`.`{1}` {2}".format(self.doctype,
meta.sort_field or "modified", meta.sort_order or "desc")
# draft docs always on top
if meta.is_submittable:
args.order_by = "`tab{0}`.docstatus asc, ".format(self.doctype) + args.order_by
args.order_by = "`tab{0}`.docstatus asc {1}"\
.format(self.doctype, (", " + args.order_by if args.order_by else ""))
def check_sort_by_table(self, order_by):
if "." in order_by: