Skip to content
Snippets Groups Projects
Commit 2ada9ac9 authored by Benjamin - Le Filament's avatar Benjamin - Le Filament
Browse files

[UPD] raise user error when deleting a liasse attached to a bdx

parent c02a2cf0
No related branches found
No related tags found
No related merge requests found
# © 2021 Le Filament (<http://www.le-filament.com>) # © 2021 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models from odoo import _, api, fields, models
from odoo.exceptions import UserError
class ScopLiasseFiscale(models.Model): class ScopLiasseFiscale(models.Model):
...@@ -358,6 +359,20 @@ class ScopLiasseFiscale(models.Model): ...@@ -358,6 +359,20 @@ class ScopLiasseFiscale(models.Model):
liasse._compute_contribution_indus() liasse._compute_contribution_indus()
liasse._compute_contribution_idf() liasse._compute_contribution_idf()
# ------------------------------------------------------
# Override ORM
# ------------------------------------------------------
def unlink(self):
for liasse in self:
if self.env["scop.bordereau"].search([("liasse_fiscale_id", "=", liasse.id)]):
raise UserError(
_(
"Il n'est pas possible de supprimer cette liasse, elle est liée "
"à un bordereau de cotisation."
)
)
return super().unlink()
# ------------------------------------------------------ # ------------------------------------------------------
# Business Function # Business Function
# ------------------------------------------------------ # ------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment