Added the record order to the returning records of the _get_records() method in SearchListView in the accounting application.

This commit is contained in:
依瑪貓 2020-09-10 21:06:12 +08:00
parent 7358b3ed9d
commit eb162c95df

View File

@ -781,12 +781,12 @@ class SearchListView(TemplateView):
if len(terms) == 0: if len(terms) == 0:
return [] return []
conditions = [self._get_conditions_for_term(x) for x in terms] conditions = [self._get_conditions_for_term(x) for x in terms]
if len(conditions) == 1:
return Record.objects.filter(conditions[0])
combined = conditions[0] combined = conditions[0]
for x in conditions[1:]: for x in conditions[1:]:
combined = combined & x combined = combined & x
return Record.objects.filter(combined) return Record.objects.filter(combined)\
.order_by("transaction__date", "transaction__ord", "is_credit",
"ord")
@staticmethod @staticmethod
def _get_conditions_for_term(term: str) -> Q: def _get_conditions_for_term(term: str) -> Q: