Use pre_delete signal insted of Model.delete() to prevent note balance issues when deleting a transaction (don't do it) in Django Admin
This commit is contained in:
parent
cc5996121b
commit
1023c6c502
3 changed files with 14 additions and 9 deletions
|
|
@ -242,14 +242,6 @@ class Transaction(PolymorphicModel):
|
|||
self.destination._force_save = True
|
||||
self.destination.save()
|
||||
|
||||
def delete(self, **kwargs):
|
||||
"""
|
||||
Whenever we want to delete a transaction (caution with this), we ensure the transaction is invalid first.
|
||||
"""
|
||||
self.valid = False
|
||||
self.save(**kwargs)
|
||||
super().delete(**kwargs)
|
||||
|
||||
@property
|
||||
def total(self):
|
||||
return self.amount * self.quantity
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue