|
@@ -317,13 +317,14 @@ class DatabaseQuery(object): |
|
|
) and not self.group_by) |
|
|
) and not self.group_by) |
|
|
|
|
|
|
|
|
if not group_function_without_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 |
|
|
# draft docs always on top |
|
|
if meta.is_submittable: |
|
|
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): |
|
|
def check_sort_by_table(self, order_by): |
|
|
if "." in order_by: |
|
|
if "." in order_by: |
|
|