mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-19 13:32:08 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
24
odoo-bringout-oca-dms-dms/dms/models/base.py
Normal file
24
odoo-bringout-oca-dms-dms/dms/models/base.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# Copyright 2021 Tecnativa - Jairo Llopis
|
||||
# Copyright 2024 Tecnativa - Víctor Martínez
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class Base(models.AbstractModel):
|
||||
_inherit = "base"
|
||||
|
||||
def unlink(self):
|
||||
"""Cascade DMS related resources removal.
|
||||
Avoid executing in ir.* models (ir.mode, ir.model.fields, etc), in transient
|
||||
models and in the models we want to check."""
|
||||
result = super().unlink()
|
||||
if (
|
||||
not self._name.startswith("ir.")
|
||||
and not self.is_transient()
|
||||
and self._name not in ("dms.file", "dms.directory")
|
||||
):
|
||||
domain = [("res_model", "=", self._name), ("res_id", "in", self.ids)]
|
||||
self.env["dms.file"].sudo().search(domain).unlink()
|
||||
self.env["dms.directory"].sudo().search(domain).unlink()
|
||||
return result
|
||||
Loading…
Add table
Add a link
Reference in a new issue