[FIX] mrp: mrp_workorder uninstall
- Install 'quality_mrp_workorder' without demo data - Go to the General Settings A warning is raised regarding the uninstallation of 'mrp_workorder'. This is due to `_onchange_group_mrp_routings`, which assumes that the installation of 'mrp_workorder' is only linked to the group `group_mrp_routings`. This is incorrect: `group_mrp_routings` might not be activated, but it might be in the dependencies of another module. Therefore, we change the logic: if we activate `group_mrp_routings`, we install 'mrp_workorder'. If we deactivate `group_mrp_routings` we do not uninstall 'mrp_workorder' if it is already installed, since it might be required by a dependancy. opw-1970910 closes odoo/odoo#32811 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
@@ -24,4 +24,13 @@ class ResConfigSettings(models.TransientModel):
|
||||
|
||||
@api.onchange('group_mrp_routings')
|
||||
def _onchange_group_mrp_routings(self):
|
||||
self.module_mrp_workorder = self.group_mrp_routings
|
||||
# If we activate 'MRP Work Orders', it means that we need to install 'mrp_workorder'.
|
||||
# The opposite is not always true: other modules (such as 'quality_mrp_workorder') may
|
||||
# depend on 'mrp_workorder', so we should not automatically uninstall the module if 'MRP
|
||||
# Work Orders' is deactivated.
|
||||
# Long story short: if 'mrp_workorder' is already installed, we don't uninstall it based on
|
||||
# group_mrp_routings
|
||||
if self.group_mrp_routings:
|
||||
self.module_mrp_workorder = True
|
||||
elif not self.env['ir.module.module'].search([('name', '=', 'mrp_workorder'), ('state', '=', 'installed')]):
|
||||
self.module_mrp_workorder = False
|
||||
|
||||
Reference in New Issue
Block a user