[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
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m31s
This commit is contained in:
@@ -14,23 +14,27 @@ class TestBankStatementLineCreation(TransactionCase):
|
||||
)
|
||||
cls.partner = cls.env["res.partner"].create({"name": "Test Partner"})
|
||||
|
||||
def test_create_blocks_creation_when_not_allowed(self):
|
||||
"""Test that create raises UserError when creation is not allowed."""
|
||||
def test_manual_create_blocks_when_not_allowed(self):
|
||||
"""Test that manual creation from UI raises UserError when not allowed."""
|
||||
self.bank_journal.allow_bank_statement_line_creation = False
|
||||
|
||||
with self.assertRaises(UserError):
|
||||
self.env["account.bank.statement.line"].create({
|
||||
self.env["account.bank.statement.line"].with_context(
|
||||
action_name="action_bank_statement_tree"
|
||||
).create({
|
||||
"journal_id": self.bank_journal.id,
|
||||
"amount": 100.0,
|
||||
"payment_ref": "Test",
|
||||
"date": "2024-01-01",
|
||||
})
|
||||
|
||||
def test_create_allows_creation_when_allowed(self):
|
||||
"""Test that create works when creation is allowed."""
|
||||
def test_manual_create_works_when_allowed(self):
|
||||
"""Test that manual creation from UI works when allowed."""
|
||||
self.bank_journal.allow_bank_statement_line_creation = True
|
||||
|
||||
line = self.env["account.bank.statement.line"].create({
|
||||
line = self.env["account.bank.statement.line"].with_context(
|
||||
action_name="action_bank_statement_tree"
|
||||
).create({
|
||||
"journal_id": self.bank_journal.id,
|
||||
"amount": 100.0,
|
||||
"payment_ref": "Test",
|
||||
@@ -38,3 +42,17 @@ class TestBankStatementLineCreation(TransactionCase):
|
||||
})
|
||||
|
||||
self.assertTrue(line.exists())
|
||||
|
||||
def test_programmatic_create_works_even_when_not_allowed(self):
|
||||
"""Test that creation without UI context (e.g. OFX import, pulling online bank statements)
|
||||
works even when manual creation is not allowed."""
|
||||
self.bank_journal.allow_bank_statement_line_creation = False
|
||||
|
||||
line = self.env["account.bank.statement.line"].create({
|
||||
"journal_id": self.bank_journal.id,
|
||||
"amount": 100.0,
|
||||
"payment_ref": "Test Import",
|
||||
"date": "2024-01-01",
|
||||
})
|
||||
|
||||
self.assertTrue(line.exists())
|
||||
|
||||
Reference in New Issue
Block a user