Simplified the "can_delete" pseudo property of the JournalEntry data model. SQLAlchemy caches the query result. There is no need to cache the result again.
This commit is contained in:
parent
6fd37b21d9
commit
863d7a9368
@ -618,14 +618,10 @@ class JournalEntry(db.Model):
|
||||
|
||||
:return: True if the journal entry can be deleted, or False otherwise.
|
||||
"""
|
||||
if not hasattr(self, "__can_delete"):
|
||||
def has_offset() -> bool:
|
||||
for line_item in self.line_items:
|
||||
if len(line_item.offsets) > 0:
|
||||
return True
|
||||
return False
|
||||
setattr(self, "__can_delete", not has_offset())
|
||||
return getattr(self, "__can_delete")
|
||||
return True
|
||||
|
||||
def delete(self) -> None:
|
||||
"""Deletes the journal entry.
|
||||
|
Loading…
Reference in New Issue
Block a user