[IMP] account_usability_misc: do not hide bank statement lines creation buttons
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:
@@ -19,6 +19,7 @@ class AccountBankStatement(models.Model):
|
||||
class AccountBankStatementLine(models.Model):
|
||||
_inherit = "account.bank.statement.line"
|
||||
|
||||
# This function is called when a user opens the form to create a new bank statement line
|
||||
@api.model
|
||||
def default_get(self, fields_list):
|
||||
res = super().default_get(fields_list)
|
||||
@@ -32,19 +33,6 @@ class AccountBankStatementLine(models.Model):
|
||||
)
|
||||
return res
|
||||
|
||||
@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:
|
||||
|
||||
@@ -23,18 +23,6 @@ class TestBankStatementLineCreation(TransactionCase):
|
||||
default_journal_id=self.bank_journal.id
|
||||
).default_get(["journal_id", "amount", "payment_ref"])
|
||||
|
||||
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_default_get_allows_creation_when_allowed(self):
|
||||
"""Test that default_get works when creation is allowed."""
|
||||
self.bank_journal.allow_bank_statement_line_creation = True
|
||||
@@ -45,16 +33,3 @@ class TestBankStatementLineCreation(TransactionCase):
|
||||
).default_get(["journal_id", "amount", "payment_ref"])
|
||||
|
||||
self.assertIsInstance(result, dict)
|
||||
|
||||
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