Revised the is_dirty method of the transaction data model in the accounting application.
This commit is contained in:
parent
eb9e4e7fe4
commit
f6c1beb824
@ -170,7 +170,7 @@ class Transaction(DirtyFieldsMixin, models.Model):
|
|||||||
return reverse(
|
return reverse(
|
||||||
"accounting:transactions.detail", args=("transfer", self))
|
"accounting:transactions.detail", args=("transfer", self))
|
||||||
|
|
||||||
def is_dirty(self, **kwargs):
|
def is_dirty(self, check_relationship=False, check_m2m=None):
|
||||||
"""Returns whether the data of this transaction is changed and need
|
"""Returns whether the data of this transaction is changed and need
|
||||||
to be saved into the database.
|
to be saved into the database.
|
||||||
|
|
||||||
@ -178,9 +178,13 @@ 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(**kwargs):
|
if super(Transaction, self).is_dirty(
|
||||||
|
check_relationship=check_relationship,
|
||||||
|
check_m2m=check_m2m):
|
||||||
return True
|
return True
|
||||||
if len([x for x in self.records if x.is_dirty(**kwargs)]) > 0:
|
if len([x for x in self.records
|
||||||
|
if x.is_dirty(check_relationship=check_relationship,
|
||||||
|
check_m2m=check_m2m)]) > 0:
|
||||||
return True
|
return True
|
||||||
kept = [x.pk for x in self.records]
|
kept = [x.pk for x in self.records]
|
||||||
if len([x for x in self.record_set.all() if x.pk not in kept]) > 0:
|
if len([x for x in self.record_set.all() if x.pk not in kept]) > 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user