New account advanced protection features module #23

Open
mondot wants to merge 8 commits from new_account_advanced_protection_features into 16.0
4 changed files with 19 additions and 0 deletions
Showing only changes of commit 0785c49c96 - Show all commits

View File

@@ -1,2 +1,3 @@
from . import account_move
from . import account_journal
from . import account_bank_statement

View File

@@ -0,0 +1,13 @@
from odoo import models, _
from odoo.exceptions import UserError
class AccountBankStatement(models.Model):
_inherit = "account.bank.statement"
def unlink(self):
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}.")
)
return super(AccountBankStatement, self).unlink()

View File

@@ -5,3 +5,4 @@ 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")

View File

@@ -13,6 +13,10 @@
name="prevent_reset_to_draft_sent_invoice"
attrs="{'invisible': [('type', '!=', 'sale')]}"
/>
<field
name="allow_bank_statement_deletion"
attrs="{'invisible': [('type', 'not in', ['bank', 'cash'])]}"
/>
</xpath>
</field>
</record>