[IMP] account_usability_misc: do not hide bank statement lines creation buttons
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m31s

This commit is contained in:
2026-01-20 19:05:50 +01:00
parent 83a796a36d
commit 43c93fa093
6 changed files with 4 additions and 91 deletions

View File

@@ -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:

View File

@@ -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())

View File

@@ -13,11 +13,9 @@ Use Odoo normal module installation procedure to install
Description
===========
- Removes the right to unlink bank statements and bank statement lines for all users
- Changes some french translation
- On reconcile view : filter account move lines by defaut with journal type
- Hide Create button in Bank Statement tree view
- Create a technical group with unlink righ on bank statements and bank statement lines
- On bills list view (i.e factures fournisseurs) : add the column Message attachment count (i.e nombre de pièces jointes)
Known issues / Roadmap
======================

View File

@@ -10,14 +10,11 @@
'depends': [
'account',
'base',
'account_reconcile_oca',
'account_statement_base',
'account_reconcile_oca'
],
'data': [
'views/account_search.xml',
'views/account_tree_view.xml',
'views/bank_statement_line_views.xml',
'views/bank_statement_views.xml',
'views/account_tree_view.xml'
],
'installable': True,
'auto_install': False,

View File

@@ -1,32 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<!-- Hide Create button in line view -->
<record id="account_bank_statement_line_tree_inherit_hide_create" model="ir.ui.view">
<field name="name">account.bank.statement.line.tree.inherit.hide.create</field>
<field name="model">account.bank.statement.line</field>
<field name="inherit_id" ref="account_statement_base.account_bank_statement_line_tree"/>
<field name="arch" type="xml">
<xpath expr="//tree" position="attributes">
<attribute name="create">false</attribute>
</xpath>
</field>
</record>
<!-- Hide Create button in kanban view -->
<record id="account_bank_statement_line_kanban_inherit_hide_create" model="ir.ui.view">
<field name="name">account.bank.statement.line.kanban.inherit.hide.create</field>
<field name="model">account.bank.statement.line</field>
<field name="inherit_id" ref="account_reconcile_oca.bank_statement_line_reconcile_view"/>
<field name="arch" type="xml">
<xpath expr="//kanban" position="attributes">
<attribute name="create">false</attribute>
</xpath>
</field>
</record>
</data>
</odoo>

View File

@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_bank_statement_tree" model="ir.ui.view">
<field name="name">account.bank.statement.tree</field>
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_tree" />
<field name="arch" type="xml">
<tree position="attributes">
<attribute name="create">false</attribute>
</tree>
</field>
</record>
</odoo>