IMP] account_advanced_protection_features: add option allow_bank_statement_line_creation
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from odoo import models, _
|
||||
from odoo import api, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
class AccountBankStatement(models.Model):
|
||||
@@ -19,6 +19,19 @@ class AccountBankStatement(models.Model):
|
||||
class AccountBankStatementLine(models.Model):
|
||||
_inherit = "account.bank.statement.line"
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
for vals in vals_list:
|
||||
journal_id = vals.get("journal_id")
|
||||
if journal_id:
|
||||
journal = self.env["account.journal"].browse(journal_id)
|
||||
if not journal.allow_bank_statement_line_creation:
|
||||
raise UserError(
|
||||
_("Manual creation of bank statement lines is not allowed for the journal %s.")
|
||||
% journal.display_name
|
||||
)
|
||||
return super().create(vals_list)
|
||||
|
||||
def unlink(self):
|
||||
for line in self:
|
||||
if not line.journal_id.allow_bank_statement_deletion:
|
||||
|
||||
@@ -10,3 +10,7 @@ class AccountJournal(models.Model):
|
||||
help="Users with group Show Full Accounting Features (id: group_account_user) will be allowed to delete account bank statements "
|
||||
"and bank statement lines."
|
||||
)
|
||||
allow_bank_statement_line_creation = fields.Boolean(
|
||||
"Allow manual bank statement lines creation",
|
||||
help="If unchecked, users will not be allowed to manually create bank statement lines for this journal."
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user