From e437d7fdf24bb1f0c3de4910784f0f2062545e07 Mon Sep 17 00:00:00 2001 From: Quentin Mondot Date: Fri, 29 Aug 2025 10:36:33 +0200 Subject: [PATCH] [IMP] account_advanced_protection_features: control bank statement lines deletion with allow_bank_statement_deletion journal param --- .../i18n/fr.po | 48 ++++++++++++++----- .../models/account_bank_statement.py | 17 ++++++- .../models/account_journal.py | 6 ++- 3 files changed, 58 insertions(+), 13 deletions(-) diff --git a/account_advanced_protection_features/i18n/fr.po b/account_advanced_protection_features/i18n/fr.po index 775e91b..c223027 100644 --- a/account_advanced_protection_features/i18n/fr.po +++ b/account_advanced_protection_features/i18n/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-22 08:18+0000\n" -"PO-Revision-Date: 2025-08-22 08:18+0000\n" +"POT-Creation-Date: 2025-08-29 08:28+0000\n" +"PO-Revision-Date: 2025-08-29 08:28+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,13 +16,13 @@ msgstr "" "Plural-Forms: \n" #. module: account_advanced_protection_features -#: model:res.groups,name:account_advanced_protection_features.group_account_advanced_manager +#: model:res.groups,name:account_advanced_protection_features.group_account_protection_manager msgid "Access to account advanced protection features" msgstr "Accès aux fonctionnalités avancées de protection des journaux" #. module: account_advanced_protection_features #: model:ir.model.fields,field_description:account_advanced_protection_features.field_account_journal__allow_bank_statement_deletion -msgid "Allow bank statement deletion" +msgid "Allow bank statements deletion" msgstr "Autoriser la suppression de relevé bancaire" #. module: account_advanced_protection_features @@ -30,6 +30,11 @@ msgstr "Autoriser la suppression de relevé bancaire" msgid "Bank Statement" msgstr "Relevé bancaire" +#. module: account_advanced_protection_features +#: model:ir.model,name:account_advanced_protection_features.model_account_bank_statement_line +msgid "Bank Statement Line" +msgstr "Ligne de relevé de compte" + #. module: account_advanced_protection_features #: model:ir.model,name:account_advanced_protection_features.model_account_journal msgid "Journal" @@ -50,20 +55,41 @@ msgstr "Empêcher la suppression des pièces comptables déjà confirmées" msgid "Prevent to reset to draft a sent invoice" msgstr "Empêcher la remise en brouillon d'une facture envoyée" -#. module: account_advanced_protection_features -#: model:ir.model.fields,field_description:account_advanced_protection_features.field_account_bank_statement_line__sent_by_email -#: model:ir.model.fields,field_description:account_advanced_protection_features.field_account_move__sent_by_email -#: model:ir.model.fields,field_description:account_advanced_protection_features.field_account_payment__sent_by_email -msgid "Sent By Email" -msgstr "Envoyée par email" - #. module: account_advanced_protection_features #: model:ir.model.fields,field_description:account_advanced_protection_features.field_account_bank_statement__smart_search +#: model:ir.model.fields,field_description:account_advanced_protection_features.field_account_bank_statement_line__smart_search #: model:ir.model.fields,field_description:account_advanced_protection_features.field_account_journal__smart_search #: model:ir.model.fields,field_description:account_advanced_protection_features.field_account_move__smart_search msgid "Smart Search" msgstr "" +#. module: account_advanced_protection_features +#. odoo-python +#: 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." + +#. module: account_advanced_protection_features +#. odoo-python +#: 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 "" +"La suppression des relevés bancaires n'est pas autorisée pour le journal %s." + +#. module: account_advanced_protection_features +#: model:ir.model.fields,help:account_advanced_protection_features.field_account_journal__allow_bank_statement_deletion +msgid "" +"Users with group Show Full Accounting Features (id: group_account_user) will" +" be allowed to delete account bank statements and bank statement lines." +msgstr "" +"Les utilisateurs avec le groupe 'Montrer les fonctions de comptabilité " +"complètes' seront autorisés à supprimer les relevés bancaires ainsi que les " +"lignes de relevés bancaires." + #. module: account_advanced_protection_features #. odoo-python #: code:addons/account_advanced_protection_features/models/account_move.py:0 diff --git a/account_advanced_protection_features/models/account_bank_statement.py b/account_advanced_protection_features/models/account_bank_statement.py index e867a00..79093b3 100644 --- a/account_advanced_protection_features/models/account_bank_statement.py +++ b/account_advanced_protection_features/models/account_bank_statement.py @@ -8,6 +8,21 @@ class AccountBankStatement(models.Model): for statement in self: if not statement.journal_id.allow_bank_statement_deletion: raise UserError( - _(f"The deletion of bank statements is not allowed for the journal {statement.journal_id.display_name}.") + _("The deletion of bank statements is not allowed for the journal %s.") % statement.journal_id.display_name ) + # we delete all the statement lines before deleting the statement itself + for line in statement.line_ids: + line.unlink() return super(AccountBankStatement, self).unlink() + + +class AccountBankStatementLine(models.Model): + _inherit = "account.bank.statement.line" + + def unlink(self): + for line in self: + if not line.journal_id.allow_bank_statement_deletion: + raise UserError( + _("The deletion of bank statement lines is not allowed for the journal %s.") % line.journal_id.display_name + ) + return super(AccountBankStatementLine, self).unlink() diff --git a/account_advanced_protection_features/models/account_journal.py b/account_advanced_protection_features/models/account_journal.py index 9a2c628..94755d2 100644 --- a/account_advanced_protection_features/models/account_journal.py +++ b/account_advanced_protection_features/models/account_journal.py @@ -5,4 +5,8 @@ class AccountJournal(models.Model): prevent_reset_to_draft_sent_invoice = fields.Boolean("Prevent to reset to draft a sent invoice") prevent_deletion_of_posted_account_move = fields.Boolean("Prevent to delete an already posted account move") - allow_bank_statement_deletion = fields.Boolean("Allow bank statement deletion") + allow_bank_statement_deletion = fields.Boolean( + "Allow bank statements deletion", + help="Users with group Show Full Accounting Features (id: group_account_user) will be allowed to delete account bank statements " + "and bank statement lines." + )