[FIX] mrp: archive operations when deactivating WO

When we deactivate the work orders in the settings, new MOs still
use operations that were assigned to the BoM, it just does not show the
Operations tab. We fix that by archiving the operations when work orders
are deactivated in the settings.

closes odoo/odoo#66108

Related: odoo/upgrade#2344
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
Nicolas Pierre
2021-04-14 07:48:16 +00:00
parent d5270c1c8a
commit 1355c9694e
2 changed files with 6 additions and 2 deletions
+1
View File
@@ -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,
+5 -2
View File
@@ -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