diff --git a/HISTORY.rst b/HISTORY.rst index dbc4043f4d..bf06ce4f71 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -9,7 +9,7 @@ to Jesaja Everling (@jeverling) for the report. - Sort the list of root cabinets. Thanks to Thomas Plotkowiak for the request. - +- Sort the list of a document's cabinets. 2.7.1 (2017-09-03) ================== diff --git a/mayan/apps/cabinets/apps.py b/mayan/apps/cabinets/apps.py index 5a45775ed3..ea945817ce 100644 --- a/mayan/apps/cabinets/apps.py +++ b/mayan/apps/cabinets/apps.py @@ -48,9 +48,11 @@ class CabinetsApp(MayanAppConfig): APIEndPoint(app=self, version_string='1') + # Add explicit order_by as DocumentCabinet ordering Meta option has no + # effect. Document.add_to_class( 'document_cabinets', - lambda document: DocumentCabinet.objects.filter(documents=document) + lambda document: DocumentCabinet.objects.filter(documents=document).order_by('parent__label', 'label') ) ModelPermission.register(