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.

This commit is contained in:
依瑪貓 2020-08-02 14:08:38 +08:00
parent 7acef78d5d
commit a78cbb2ad8

View File

@ -143,6 +143,7 @@ class Transaction(DirtyFieldsMixin, models.Model):
""" """
if self._records is None: if self._records is None:
self._records = list(self.record_set.all()) self._records = list(self.record_set.all())
self._records.sort(key=lambda x: (x.is_credit, x.ord))
return self._records return self._records
@records.setter @records.setter