Revised the delete method of the transaction data model so that the reorder will not pass the save() method and induce complex reorder in the accounting application.
This commit is contained in:
parent
2986d6d231
commit
785087fc8c
@ -245,15 +245,14 @@ class Transaction(DirtyFieldsMixin, models.Model):
|
|||||||
.order_by("ord"))
|
.order_by("ord"))
|
||||||
txn_to_sort = []
|
txn_to_sort = []
|
||||||
for i in range(len(txn_same_day)):
|
for i in range(len(txn_same_day)):
|
||||||
txn_same_day[i].ord = i + 1
|
if txn_same_day[i].ord != i + 1:
|
||||||
if txn_same_day[i].is_dirty():
|
txn_to_sort.append([txn_same_day[i], i + 1])
|
||||||
txn_to_sort.append(txn_same_day[i])
|
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
for record in self.record_set.all():
|
for record in self.record_set.all():
|
||||||
record.delete()
|
record.delete()
|
||||||
super().delete(using=using, keep_parents=keep_parents)
|
super().delete(using=using, keep_parents=keep_parents)
|
||||||
for txn in txn_to_sort:
|
for x in txn_to_sort:
|
||||||
txn.save()
|
Transaction.objects.filter(pk=x[0].pk).update(ord=x[1])
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = "accounting_transactions"
|
db_table = "accounting_transactions"
|
||||||
|
Loading…
Reference in New Issue
Block a user