From 6c702172ec585c9dff36d518d1670e2e753a6c8d Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 18 Apr 2019 14:22:44 +0000 Subject: [PATCH] [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) --- addons/mrp/models/res_config_settings.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/mrp/models/res_config_settings.py b/addons/mrp/models/res_config_settings.py index 5e47515b1f3..dcda06cb4c2 100644 --- a/addons/mrp/models/res_config_settings.py +++ b/addons/mrp/models/res_config_settings.py @@ -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