Skip to content

Commit 7abefa1

Browse files
committed
[IMP] Allow to unlink modules
1 parent a8081c4 commit 7abefa1

3 files changed

Lines changed: 28 additions & 6 deletions

File tree

vcp_odoo/models/vcp_odoo_bin_package.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Copyright 2026 Dixmit
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
33

4-
from odoo import fields, models, tools
4+
from odoo import _, api, fields, models, tools
5+
from odoo.exceptions import UserError
56

67

78
class VcpOdooBinPackage(models.Model):
@@ -22,3 +23,13 @@ def _get_bin_package(self, name):
2223
if not bin_src:
2324
bin_src = self.create({"name": name})
2425
return bin_src.id
26+
27+
@api.ondelete(at_uninstall=False)
28+
def _check_module_versions(self):
29+
if self.mapped("module_version_ids"):
30+
raise UserError(
31+
_(
32+
"You can not delete packages that are related to Odoo Modules. "
33+
"You should first delete the related odoo modules."
34+
)
35+
)

vcp_odoo/models/vcp_odoo_python_library.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Copyright 2026 Dixmit
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
33

4-
from odoo import fields, models, tools
4+
from odoo import _, api, fields, models, tools
5+
from odoo.exceptions import UserError
56

67

78
class VcpOdooPythonLibrary(models.Model):
@@ -22,3 +23,13 @@ def _get_python_library(self, name):
2223
if not lib:
2324
lib = self.create({"name": name})
2425
return lib.id
26+
27+
@api.ondelete(at_uninstall=False)
28+
def _check_module_versions(self):
29+
if self.mapped("module_version_ids"):
30+
raise UserError(
31+
_(
32+
"You can not delete librairies that are related to Odoo Modules. "
33+
"You should first delete the related odoo modules."
34+
)
35+
)
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
22
access_vcp_odoo_module,Access Odoo Module,model_vcp_odoo_module,vcp_management.group_vcp_user,1,0,0,0
3-
manage_vcp_odoo_module,Manage Odoo Module,model_vcp_odoo_module,vcp_management.group_vcp_manager,1,1,1,0
3+
manage_vcp_odoo_module,Manage Odoo Module,model_vcp_odoo_module,vcp_management.group_vcp_manager,1,1,1,1
44
access_vcp_odoo_module_version,Access Odoo Module Version,model_vcp_odoo_module_version,vcp_management.group_vcp_user,1,0,0,0
5-
manage_vcp_odoo_module_version,Manage Odoo Module Version,model_vcp_odoo_module_version,vcp_management.group_vcp_manager,1,1,1,0
5+
manage_vcp_odoo_module_version,Manage Odoo Module Version,model_vcp_odoo_module_version,vcp_management.group_vcp_manager,1,1,1,1
66
access_vcp_odoo_bin_package,Access Odoo Bin Package,model_vcp_odoo_bin_package,vcp_management.group_vcp_user,1,0,0,0
7-
manage_vcp_odoo_bin_package,Manage Odoo Bin Package,model_vcp_odoo_bin_package,vcp_management.group_vcp_manager,1,1,1,0
7+
manage_vcp_odoo_bin_package,Manage Odoo Bin Package,model_vcp_odoo_bin_package,vcp_management.group_vcp_manager,1,1,1,1
88
access_vcp_odoo_python_library,Access Odoo Python Library,model_vcp_odoo_python_library,vcp_management.group_vcp_user,1,0,0,0
9-
manage_vcp_odoo_python_library,Manage Odoo Python Library,model_vcp_odoo_python_library,vcp_management.group_vcp_manager,1,1,1,0
9+
manage_vcp_odoo_python_library,Manage Odoo Python Library,model_vcp_odoo_python_library,vcp_management.group_vcp_manager,1,1,1,1

0 commit comments

Comments
 (0)