1 Commits

Author SHA1 Message Date
Boris Gallet
45da780609 [NEW] account_invoice_protect_deleting 2024-03-27 11:08:05 +01:00
9 changed files with 25 additions and 45 deletions

View File

@@ -1,5 +1,5 @@
===============
account_move_protect_deleting
account_invoice_protect_deleting
===============
Forbid to delete an invoice that has been already validated
@@ -8,7 +8,7 @@ Installation
============
Use Odoo normal module installation procedure to install
``account_move_protect_deleting``.
``account_invoice_protect_deleting``.
Known issues / Roadmap
======================
@@ -18,7 +18,7 @@ None yet.
Bug Tracker
===========
Bugs are tracked on `our issues website <https://github.com/elabore-coop/account_move_protect_deleting/issues>`_. In case of
Bugs are tracked on `our issues website <https://github.com/elabore-coop/account_invoice_protect_deleting/issues>`_. In case of
trouble, please check there if your issue has already been
reported. If you spotted it first, help us smashing it by providing a
detailed and welcomed feedback.

View File

@@ -2,14 +2,14 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "account_move_protect_deleting",
"name": "account_invoice_protect_deleting",
"version": "16.0.1.0.0",
"author": "Elabore",
"website": "https://elabore.coop",
"maintainer": "Boris Gallet",
"license": "AGPL-3",
"category": "Tools",
"summary": "Forbid to delete an account move that has already been posted",
"summary": "Forbid to delete an account move that has already been validated",
# any module necessary for this one to work correctly
"depends": [
"base",

View File

@@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_move_protect_deleting
# * account_invoice_protect_deleting
#
msgid ""
msgstr ""
@@ -15,9 +15,9 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: account_move_protect_deleting
#. module: account_invoice_protect_deleting
#. odoo-python
#: code:addons/account_move_protect_deleting/models/account_move.py:0
#: code:addons/account_invoice_protect_deleting/models/account_move.py:0
#, python-format
msgid "You cannot delete this account move because it has been posted."
msgstr "Vous ne pouvez pas supprimer cette pièce comptable car elle à déjà été confirmée."
msgid "You cannot delete this account move because it has been validated."
msgstr "Vous ne pouvez pas supprimer cette pièce comptable car elle à déjà été validée."

View File

@@ -0,0 +1,15 @@
from odoo import models, api, _
from odoo.exceptions import UserError
class AccountMove(models.Model):
_inherit = 'account.move'
@api.ondelete(at_uninstall=False)
def _check_name(self):
""" Prevent deletion of a account move if it has been posted "/"
"""
if (self.posted_before) :
raise UserError(_(""
"You cannot delete this account move because it has been validated."
))

View File

@@ -1,35 +0,0 @@
from odoo import models, api, _
from odoo.exceptions import UserError
class AccountMove(models.Model):
_inherit = 'account.move'
@api.ondelete(at_uninstall=False)
def _check_posted(self):
""" Prevent deletion of a account move if it has been posted
exeptions : Check deposit or Cash deposit. In V16 in odoo the account move is deleted
when the check deposit is reset to draft.
This work the same with Cash deposit
"""
# search in account.cash.deposit if account move is this one
for cash_deposit in self.env['account.cash.deposit'].search([]):
if cash_deposit.move_id == self:
print (cash_deposit.move_id, self)
is_cash_deposit = True
# search in account.check.deposit if account move is this one
for check_deposit in self.env['account.check.deposit'].search([]):
if check_deposit.move_id == self:
is_check_deposit = True
if (
self.posted_before and
(
not is_cash_deposit
and not is_check_deposit
)
):
raise UserError(_(""
"You cannot delete this account move because it has been posted."
))