[IMP] account_advanced_protection_features: control bank statement lines deletion with allow_bank_statement_deletion journal param
This commit is contained in:
@@ -8,6 +8,21 @@ class AccountBankStatement(models.Model):
|
||||
for statement in self:
|
||||
if not statement.journal_id.allow_bank_statement_deletion:
|
||||
raise UserError(
|
||||
_(f"The deletion of bank statements is not allowed for the journal {statement.journal_id.display_name}.")
|
||||
_("The deletion of bank statements is not allowed for the journal %s.") % statement.journal_id.display_name
|
||||
)
|
||||
# we delete all the statement lines before deleting the statement itself
|
||||
for line in statement.line_ids:
|
||||
line.unlink()
|
||||
return super(AccountBankStatement, self).unlink()
|
||||
|
||||
|
||||
class AccountBankStatementLine(models.Model):
|
||||
_inherit = "account.bank.statement.line"
|
||||
|
||||
def unlink(self):
|
||||
for line in self:
|
||||
if not line.journal_id.allow_bank_statement_deletion:
|
||||
raise UserError(
|
||||
_("The deletion of bank statement lines is not allowed for the journal %s.") % line.journal_id.display_name
|
||||
)
|
||||
return super(AccountBankStatementLine, self).unlink()
|
||||
|
@@ -5,4 +5,8 @@ class AccountJournal(models.Model):
|
||||
|
||||
prevent_reset_to_draft_sent_invoice = fields.Boolean("Prevent to reset to draft a sent invoice")
|
||||
prevent_deletion_of_posted_account_move = fields.Boolean("Prevent to delete an already posted account move")
|
||||
allow_bank_statement_deletion = fields.Boolean("Allow bank statement deletion")
|
||||
allow_bank_statement_deletion = fields.Boolean(
|
||||
"Allow bank statements deletion",
|
||||
help="Users with group Show Full Accounting Features (id: group_account_user) will be allowed to delete account bank statements "
|
||||
"and bank statement lines."
|
||||
)
|
||||
|
Reference in New Issue
Block a user