From a78cbb2ad8d2c0f021916905e17c5298fc8dbaca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sun, 2 Aug 2020 14:08:38 +0800 Subject: [PATCH] Revised the records property of the record data model so that the returned records are sorted by their types and their orders in the accounting application. --- accounting/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/accounting/models.py b/accounting/models.py index 56caf4f..24374e9 100644 --- a/accounting/models.py +++ b/accounting/models.py @@ -143,6 +143,7 @@ class Transaction(DirtyFieldsMixin, models.Model): """ if self._records is None: self._records = list(self.record_set.all()) + self._records.sort(key=lambda x: (x.is_credit, x.ord)) return self._records @records.setter