Added the limitation so that essential accounts, like cash, and the accounts in use, cannot be deleted.

This commit is contained in:
2023-03-22 00:09:06 +08:00
parent 494faeffea
commit d0d2d77a2e
4 changed files with 84 additions and 22 deletions

View File

@ -157,6 +157,9 @@ def delete_account(account: Account) -> redirect:
:return: The redirection to the account list on success, or the account
detail on error.
"""
if not account.can_delete:
flash(s(lazy_gettext("The account cannot be deleted.")), "error")
return redirect(inherit_next(__get_detail_uri(account)))
account.delete()
sort_accounts_in(account.base_code, account.id)
db.session.commit()