Simplified the super method calls in the data models in the accounting application.

This commit is contained in:
依瑪貓 2020-08-12 22:29:03 +08:00
parent 3f250d9958
commit 2986d6d231

View File

@ -76,9 +76,8 @@ class Account(DirtyFieldsMixin, models.Model):
if current_user is not None: if current_user is not None:
self.updated_by = current_user self.updated_by = current_user
with transaction.atomic(): with transaction.atomic():
super(Account, self).save( super().save(force_insert=force_insert, force_update=force_update,
force_insert=force_insert, force_update=force_update, using=using, update_fields=update_fields)
using=using, update_fields=update_fields)
class Meta: class Meta:
db_table = "accounting_accounts" db_table = "accounting_accounts"
@ -178,9 +177,8 @@ class Transaction(DirtyFieldsMixin, models.Model):
bool: True if the data of this transaction is changed and need bool: True if the data of this transaction is changed and need
to be saved into the database, or False otherwise. to be saved into the database, or False otherwise.
""" """
if super(Transaction, self).is_dirty( if super().is_dirty(check_relationship=check_relationship,
check_relationship=check_relationship, check_m2m=check_m2m):
check_m2m=check_m2m):
return True return True
if len([x for x in self.records if len([x for x in self.records
if x.is_dirty(check_relationship=check_relationship, if x.is_dirty(check_relationship=check_relationship,
@ -253,8 +251,7 @@ class Transaction(DirtyFieldsMixin, models.Model):
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(Transaction, self).delete( super().delete(using=using, keep_parents=keep_parents)
using=using, keep_parents=keep_parents)
for txn in txn_to_sort: for txn in txn_to_sort:
txn.save() txn.save()