diff --git a/taiga/projects/attachments/utils.py b/taiga/projects/attachments/utils.py index 33e36c44..5103fccb 100644 --- a/taiga/projects/attachments/utils.py +++ b/taiga/projects/attachments/utils.py @@ -37,7 +37,8 @@ def attach_basic_attachments(queryset, as_field="attachments_attr"): attachments_attachment.id, attachments_attachment.attached_file FROM attachments_attachment - WHERE attachments_attachment.object_id = {tbl}.id AND attachments_attachment.content_type_id = {type_id}) t""" + WHERE attachments_attachment.object_id = {tbl}.id AND attachments_attachment.content_type_id = {type_id} + ORDER BY attachments_attachment.order, attachments_attachment.id) t""" sql = sql.format(tbl=model._meta.db_table, type_id=type.id) queryset = queryset.extra(select={as_field: sql}) diff --git a/taiga/projects/userstories/utils.py b/taiga/projects/userstories/utils.py index 87b8e094..35456b71 100644 --- a/taiga/projects/userstories/utils.py +++ b/taiga/projects/userstories/utils.py @@ -89,7 +89,10 @@ def attach_tasks(queryset, as_field="tasks_attr"): projects_taskstatus.is_closed FROM tasks_task INNER JOIN projects_taskstatus on projects_taskstatus.id = tasks_task.status_id - WHERE user_story_id = {tbl}.id) t""" + WHERE user_story_id = {tbl}.id + ORDER BY tasks_task.us_order, tasks_task.ref + ) t + """ sql = sql.format(tbl=model._meta.db_table) queryset = queryset.extra(select={as_field: sql})