Revised the has_order_hole attribute of the accounting transaction data model.

This commit is contained in:
2020-07-07 19:33:34 +08:00
parent 83f97a6467
commit a26247f752
2 changed files with 15 additions and 2 deletions

View File

@ -117,8 +117,10 @@ class Transaction(models.Model):
1, 2, 3, 4, 5..., and should be reordered. """
if self._has_order_hole is None:
orders = [x.ord for x in Transaction.objects.filter(
date=self.date).order_by("-ord")]
if orders[0] != len(orders):
date=self.date)]
if max(orders) != len(orders):
self._has_order_hole = True
elif min(orders) != 1:
self._has_order_hole = True
elif len(orders) != len(set(orders)):
self._has_order_hole = True