[IMP] account_advanced_protection_features : correct the way allow_bank_statement_line_creation works
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m31s

This commit is contained in:
2026-02-03 16:17:28 +01:00
parent e1f1d748ff
commit 189b068097
2 changed files with 36 additions and 15 deletions

View File

@@ -21,15 +21,18 @@ class AccountBankStatementLine(models.Model):
@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
)
# Condition on action_name is here to check permissions only for the manual creation.
# Import of files and pulling online bank statements should not be concerned
if self.env.context.get("action_name") == "action_bank_statement_tree":
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):