[FIX] mrp: stop all timers when cancelling work order
Steps to reproduce the bug: - Create a manufacturing order to produce “Table” - Confirm and plan the MO - Start the work order - Cancel the MO Problem: - The work order is cancelled, but the timers continue to run. - "Block", "Unblock" and “Unplan" button should be hidden when MO is cancelled opw-2817842 closes odoo/odoo#89442 X-original-commit: 5682015958d03f4a65969afe3fce9b9b05e5b505 Signed-off-by: William Henrotin (whe) <whe@odoo.com> Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
This commit is contained in:
@@ -657,6 +657,7 @@ class MrpWorkorder(models.Model):
|
||||
|
||||
def action_cancel(self):
|
||||
self.leave_id.unlink()
|
||||
self.end_all()
|
||||
return self.write({'state': 'cancel'})
|
||||
|
||||
def action_replan(self):
|
||||
|
||||
@@ -2736,3 +2736,21 @@ class TestMrpOrder(TestMrpCommon):
|
||||
mo_2.action_confirm()
|
||||
mo_2.button_plan()
|
||||
self.assertEqual(mo_2.workorder_ids[0].workcenter_id.id, workcenter_2.id, 'workcenter_2 is faster than workcenter_1 to manufacture 4 units')
|
||||
|
||||
def test_timers_after_cancelling_mo(self):
|
||||
"""
|
||||
Check that the timers in the workorders are stopped after the cancellation of the MO
|
||||
"""
|
||||
mo_form = Form(self.env['mrp.production'])
|
||||
mo_form.bom_id = self.bom_2
|
||||
mo_form.product_qty = 1
|
||||
mo = mo_form.save()
|
||||
mo.action_confirm()
|
||||
mo.button_plan()
|
||||
|
||||
wo = mo.workorder_ids
|
||||
wo.button_start()
|
||||
mo.action_cancel()
|
||||
self.assertEqual(mo.state, 'cancel', 'Manufacturing order should be cancelled.')
|
||||
self.assertEqual(wo.state, 'cancel', 'Workorders should be cancelled.')
|
||||
self.assertTrue(mo.workorder_ids.time_ids.date_end, 'The timers must stop after the cancellation of the MO')
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
confirm="There are no components to consume. Are you still sure you want to continue?"/>
|
||||
<button name="action_confirm" attrs="{'invisible': [('state', '!=', 'draft')]}" string="Confirm" type="object" class="oe_highlight" data-hotkey="v"/>
|
||||
<button name="button_plan" attrs="{'invisible': ['|', '|', ('state', 'not in', ('confirmed', 'progress', 'to_close')), ('workorder_ids', '=', []), ('is_planned', '=', True)]}" type="object" string="Plan" class="oe_highlight" data-hotkey="x"/>
|
||||
<button name="button_unplan" type="object" string="Unplan" attrs="{'invisible': [('is_planned', '=', False)]}" data-hotkey="x"/>
|
||||
<button name="button_unplan" type="object" string="Unplan" attrs="{'invisible': ['|', ('is_planned', '=', False), ('state', '=', 'cancel')]}" data-hotkey="x"/>
|
||||
<button name="action_assign" attrs="{'invisible': ['|', ('state', 'in', ('draft', 'done', 'cancel')), ('reserve_visible', '=', False)]}" string="Check availability" type="object" data-hotkey="q"/>
|
||||
<button name="do_unreserve" type="object" string="Unreserve" attrs="{'invisible': [('unreserve_visible', '=', False)]}" data-hotkey="w"/>
|
||||
<button name="button_scrap" type="object" string="Scrap" attrs="{'invisible': [('state', 'in', ('cancel', 'draft'))]}" data-hotkey="z"/>
|
||||
|
||||
@@ -95,9 +95,9 @@
|
||||
<button name="button_finish" type="object" string="Done" class="btn-success"
|
||||
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/>
|
||||
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="Block" context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
|
||||
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done')), ('working_state', '=', 'blocked')]}"/>
|
||||
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked')]}"/>
|
||||
<button name="button_unblock" type="object" string="Unblock" context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
|
||||
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done')), ('working_state', '!=', 'blocked')]}"/>
|
||||
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked')]}"/>
|
||||
<button name="action_open_wizard" type="object" icon="fa-external-link" class="oe_edit_only"
|
||||
title="Open Work Order"
|
||||
context="{'default_workcenter_id': workcenter_id}"/>
|
||||
|
||||
Reference in New Issue
Block a user