Skip to content

Commit

Permalink
[IMP] mgmtsystem: warn when module to install is still not available
Browse files Browse the repository at this point in the history
  • Loading branch information
dreispt committed Dec 27, 2024
1 parent 8596993 commit 6406e23
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions mgmtsystem/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

{
"name": "Management System",
"summary": "Support for management systems, such as ISO compliance.",
"version": "18.0.1.0.0",
"author": "Savoir-faire Linux,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/management-system",
Expand Down
19 changes: 18 additions & 1 deletion mgmtsystem/models/res_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models
from odoo import _, exceptions, fields, models


class MgmtsystemConfigSettings(models.TransientModel):
Expand Down Expand Up @@ -107,3 +107,20 @@ class MgmtsystemConfigSettings(models.TransientModel):
help="Provide Work Instructions category.\n"
"- This installs the module document_page_work_instruction.",
)

def execute(self):
# Provide error in case the odule to install is not available in the system
# This avoids user confusion from the install failing silently
self = self.with_context(active_test=False)
classified = self._get_classified_fields()
to_install = [

Check warning on line 116 in mgmtsystem/models/res_config.py

View check run for this annotation

Codecov / codecov/patch

mgmtsystem/models/res_config.py#L114-L116

Added lines #L114 - L116 were not covered by tests
f[7:] for f in self._fields.keys() if f.startswith("module_") and self[f]
]
available = classified["module"].mapped("name")
not_available = set(to_install) - set(available)

Check warning on line 120 in mgmtsystem/models/res_config.py

View check run for this annotation

Codecov / codecov/patch

mgmtsystem/models/res_config.py#L119-L120

Added lines #L119 - L120 were not covered by tests
if not_available:
raise exceptions.UserError(

Check warning on line 122 in mgmtsystem/models/res_config.py

View check run for this annotation

Codecov / codecov/patch

mgmtsystem/models/res_config.py#L122

Added line #L122 was not covered by tests
_("The following modules are not available: %s")
% ", ".join(not_available)
)
return super().execute()

Check warning on line 126 in mgmtsystem/models/res_config.py

View check run for this annotation

Codecov / codecov/patch

mgmtsystem/models/res_config.py#L126

Added line #L126 was not covered by tests

0 comments on commit 6406e23

Please sign in to comment.