IMP] account_advanced_protection_features: add option allow_bank_statement_line_creation
This commit is contained in:
@@ -1 +1,2 @@
|
||||
from . import test_account_move
|
||||
from . import test_account_bank_statement
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class TestBankStatementLineCreation(TransactionCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.bank_journal = cls.env["account.journal"].search(
|
||||
[("type", "=", "bank")], limit=1
|
||||
)
|
||||
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."""
|
||||
self.bank_journal.allow_bank_statement_line_creation = False
|
||||
|
||||
with self.assertRaises(UserError):
|
||||
self.env["account.bank.statement.line"].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."""
|
||||
self.bank_journal.allow_bank_statement_line_creation = True
|
||||
|
||||
line = self.env["account.bank.statement.line"].create({
|
||||
"journal_id": self.bank_journal.id,
|
||||
"amount": 100.0,
|
||||
"payment_ref": "Test",
|
||||
"date": "2024-01-01",
|
||||
})
|
||||
|
||||
self.assertTrue(line.exists())
|
||||
Reference in New Issue
Block a user