2 Commits

Author SHA1 Message Date
e1f1d748ff [IMP] account_usability_misc: do not hide bank statement lines creation buttons
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m35s
2026-01-21 10:16:04 +01:00
fefd9a6a34 IMP] account_advanced_protection_features: add option allow_bank_statement_line_creation 2026-01-21 10:15:50 +01:00
12 changed files with 106 additions and 62 deletions

View File

@@ -3,9 +3,12 @@ account_advanced_protection_features
====================================
This module adds several protection features about accounting :
* Forbid to delete an invoice that has already been validated
* Forbid to reset to draft an invoice that has already been sent by email
* Allow bank statements and bank statement lines deletion
* Forbid bank statements and bank statement lines deletion. You can allow it per journal.
* Forbid manual bank statement lines creation. You can allow it per journal.
* Per journal, add the option to forbid to delete an invoice that has already been validated.
* Per journal, add the option to forbid to reset to draft an invoice that has already been sent by email.
Installation
============

View File

@@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "account_advanced_protection_features",
"name": "Account advanced protection features",
"version": "16.0.1.0.0",
"author": "Elabore",
"website": "https://elabore.coop",

View File

@@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-08-29 08:28+0000\n"
"PO-Revision-Date: 2025-08-29 08:28+0000\n"
"POT-Creation-Date: 2026-01-20 16:50+0000\n"
"PO-Revision-Date: 2026-01-20 16:50+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -25,6 +25,11 @@ msgstr "Accès aux fonctionnalités avancées de protection des journaux"
msgid "Allow bank statements deletion"
msgstr "Autoriser la suppression de relevé bancaire"
#. module: account_advanced_protection_features
#: model:ir.model.fields,field_description:account_advanced_protection_features.field_account_journal__allow_bank_statement_line_creation
msgid "Allow manual bank statement lines creation"
msgstr "Autoriser l'ajout manuelle des lignes de relevé bancaire"
#. module: account_advanced_protection_features
#: model:ir.model,name:account_advanced_protection_features.model_account_bank_statement
msgid "Bank Statement"
@@ -35,6 +40,13 @@ msgstr "Relevé bancaire"
msgid "Bank Statement Line"
msgstr "Ligne de relevé de compte"
#. module: account_advanced_protection_features
#: model:ir.model.fields,help:account_advanced_protection_features.field_account_journal__allow_bank_statement_line_creation
msgid ""
"If unchecked, users will not be allowed to manually create bank statement "
"lines for this journal."
msgstr "Si décoché, les utilisateurs ne seront pas autorisés à créer des lignes de relevé bancaire pour ce journal."
#. module: account_advanced_protection_features
#: model:ir.model,name:account_advanced_protection_features.model_account_journal
msgid "Journal"
@@ -45,6 +57,16 @@ msgstr ""
msgid "Journal Entry"
msgstr "Pièce comptable"
#. module: account_advanced_protection_features
#. odoo-python
#: code:addons/account_advanced_protection_features/models/account_bank_statement.py:0
#: code:addons/account_advanced_protection_features/models/account_bank_statement.py:0
#, python-format
msgid ""
"Manual creation of bank statement lines is not allowed for the journal %s."
msgstr ""
"La création manuelle de lignes de relevé bancaire n'est pas autorisée pour le journal %s."
#. module: account_advanced_protection_features
#: model:ir.model.fields,field_description:account_advanced_protection_features.field_account_journal__prevent_deletion_of_posted_account_move
msgid "Prevent to delete an already posted account move"
@@ -66,15 +88,18 @@ msgstr ""
#. module: account_advanced_protection_features
#. odoo-python
#: code:addons/account_advanced_protection_features/models/account_bank_statement.py:0
#: code:addons/account_advanced_protection_features/models/account_bank_statement.py:0
#, python-format
msgid ""
"The deletion of bank statement lines is not allowed for the journal %s."
msgstr ""
"La suppression des lignes de relevé bancaire n'est pas autorisée pour le journal %s."
"La suppression des lignes de relevé bancaire n'est pas autorisée pour le "
"journal %s."
#. module: account_advanced_protection_features
#. odoo-python
#: code:addons/account_advanced_protection_features/models/account_bank_statement.py:0
#: code:addons/account_advanced_protection_features/models/account_bank_statement.py:0
#, python-format
msgid "The deletion of bank statements is not allowed for the journal %s."
msgstr ""
@@ -93,8 +118,10 @@ msgstr ""
#. module: account_advanced_protection_features
#. odoo-python
#: code:addons/account_advanced_protection_features/models/account_move.py:0
#: code:addons/account_advanced_protection_features/models/account_move.py:0
#, python-format
msgid "You cannot delete this account move because it has already been posted."
msgid ""
"You cannot delete this account move because it has already been posted."
msgstr ""
"Vous ne pouvez pas supprimer cette pièce comptable car elle à déjà été "
"confirmée."
@@ -102,6 +129,7 @@ msgstr ""
#. module: account_advanced_protection_features
#. odoo-python
#: code:addons/account_advanced_protection_features/models/account_move.py:0
#: code:addons/account_advanced_protection_features/models/account_move.py:0
#, python-format
msgid ""
"You cannot reset to draft this invoice because it has been sent by email."

View File

@@ -1,4 +1,4 @@
from odoo import models, _
from odoo import api, models, _
from odoo.exceptions import UserError
class AccountBankStatement(models.Model):
@@ -19,6 +19,19 @@ class AccountBankStatement(models.Model):
class AccountBankStatementLine(models.Model):
_inherit = "account.bank.statement.line"
@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

@@ -10,3 +10,7 @@ class AccountJournal(models.Model):
help="Users with group Show Full Accounting Features (id: group_account_user) will be allowed to delete account bank statements "
"and bank statement lines."
)
allow_bank_statement_line_creation = fields.Boolean(
"Allow manual bank statement lines creation",
help="If unchecked, users will not be allowed to manually create bank statement lines for this journal."
)

View File

@@ -1 +1,2 @@
from . import test_account_move
from . import test_account_bank_statement

View File

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

View File

@@ -20,6 +20,11 @@
groups="account_advanced_protection_features.group_account_protection_manager"
attrs="{'invisible': [('type', 'not in', ['bank', 'cash'])]}"
/>
<field
name="allow_bank_statement_line_creation"
groups="account_advanced_protection_features.group_account_protection_manager"
attrs="{'invisible': [('type', 'not in', ['bank', 'cash'])]}"
/>
</xpath>
</field>
</record>

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>