From 6406e23ce1be459c7ad50be02cef8a1d4eed76a6 Mon Sep 17 00:00:00 2001 From: Daniel Reis Date: Fri, 27 Dec 2024 16:50:04 +0000 Subject: [PATCH] [IMP] mgmtsystem: warn when module to install is still not available --- mgmtsystem/__manifest__.py | 1 + mgmtsystem/models/res_config.py | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/mgmtsystem/__manifest__.py b/mgmtsystem/__manifest__.py index b4a9838d6b82..eebc6d02c164 100644 --- a/mgmtsystem/__manifest__.py +++ b/mgmtsystem/__manifest__.py @@ -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", diff --git a/mgmtsystem/models/res_config.py b/mgmtsystem/models/res_config.py index 6b61d8860197..6715a821ee62 100644 --- a/mgmtsystem/models/res_config.py +++ b/mgmtsystem/models/res_config.py @@ -1,7 +1,7 @@ # Copyright (C) 2004-2012 OpenERP S.A. (). # 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): @@ -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 = [ + 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) + if not_available: + raise exceptions.UserError( + _("The following modules are not available: %s") + % ", ".join(not_available) + ) + return super().execute()