diff --git a/addons/mrp/models/mrp_routing.py b/addons/mrp/models/mrp_routing.py index c710d41d799..10debde70c2 100644 --- a/addons/mrp/models/mrp_routing.py +++ b/addons/mrp/models/mrp_routing.py @@ -11,6 +11,7 @@ class MrpRoutingWorkcenter(models.Model): _check_company_auto = True name = fields.Char('Operation', required=True) + active = fields.Boolean(default=True) workcenter_id = fields.Many2one('mrp.workcenter', 'Work Center', required=True, check_company=True) sequence = fields.Integer( 'Sequence', default=100, diff --git a/addons/mrp/models/res_config_settings.py b/addons/mrp/models/res_config_settings.py index 8959aa4324c..4ddaeecd528 100644 --- a/addons/mrp/models/res_config_settings.py +++ b/addons/mrp/models/res_config_settings.py @@ -34,7 +34,10 @@ class ResConfigSettings(models.TransientModel): # Work Orders' is deactivated. # Long story short: if 'mrp_workorder' is already installed, we don't uninstall it based on # group_mrp_routings + operations = self.env['mrp.routing.workcenter'].with_context({'active_test': False}).search([('company_id', '=', self.company_id.id)]) 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 + else: + operations.action_archive() # When deactivating workorders we want to archive all the operations linked to the company + if not self.env['ir.module.module'].search([('name', '=', 'mrp_workorder'), ('state', '=', 'installed')]): + self.module_mrp_workorder = False