Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][IMP] mgmtsystem: warn when module to install is still not available #618

Open
wants to merge 1 commit into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dreispt Can we add a message pointing to the Migration issue on Github and asking people to leave a comment if they want to contribute?

% ", ".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
Loading