[IMP] account_advanced_protection_features: manage allow_bank_statement_deletion in cash and bank journals
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
from . import account_move
|
from . import account_move
|
||||||
from . import account_journal
|
from . import account_journal
|
||||||
|
from . import account_bank_statement
|
||||||
|
@@ -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()
|
@@ -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_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")
|
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")
|
||||||
|
@@ -13,6 +13,10 @@
|
|||||||
name="prevent_reset_to_draft_sent_invoice"
|
name="prevent_reset_to_draft_sent_invoice"
|
||||||
attrs="{'invisible': [('type', '!=', 'sale')]}"
|
attrs="{'invisible': [('type', '!=', 'sale')]}"
|
||||||
/>
|
/>
|
||||||
|
<field
|
||||||
|
name="allow_bank_statement_deletion"
|
||||||
|
attrs="{'invisible': [('type', 'not in', ['bank', 'cash'])]}"
|
||||||
|
/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
Reference in New Issue
Block a user