Compare commits
3 Commits
43c93fa093
...
16.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 189b068097 | |||
| e1f1d748ff | |||
| fefd9a6a34 |
@@ -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
|
||||
============
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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,22 @@ class AccountBankStatement(models.Model):
|
||||
class AccountBankStatementLine(models.Model):
|
||||
_inherit = "account.bank.statement.line"
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
# Condition on action_name is here to check permissions only for the manual creation.
|
||||
# Import of files and pulling online bank statements should not be concerned
|
||||
if self.env.context.get("action_name") == "action_bank_statement_tree":
|
||||
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:
|
||||
|
||||
@@ -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."
|
||||
)
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
from . import test_account_move
|
||||
from . import test_account_bank_statement
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
# 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_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"].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_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"].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",
|
||||
})
|
||||
|
||||
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())
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
======================
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user