From ad0555abbee0c406217da95ef440c1eae15cc7fb Mon Sep 17 00:00:00 2001 From: Walid Date: Fri, 6 Oct 2023 17:17:41 +0200 Subject: [PATCH] [FIX] mrp: End date with lead time Steps to reproduce: - Enable manufacturing lead times in settings - Create a BOM for product P with lead time 5 days - Create and process an MO for product P - End date is wrong (add date_finished to the MO list view to check) Bug: when marking MO as done the end date is correctly set as today but during the write the compute is triggered which delays it by the lead time Fix: do not modify the end date of done MOs opw-3536069 closes odoo/odoo#138431 X-original-commit: baa769a56a1236ec75a6042c56643464c2aabd3d Signed-off-by: William Henrotin (whe) Signed-off-by: Walid Hanniche (waha) --- addons/mrp/tests/test_order.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/mrp/tests/test_order.py b/addons/mrp/tests/test_order.py index b5acc16a4c6..6e1a6f16d3c 100644 --- a/addons/mrp/tests/test_order.py +++ b/addons/mrp/tests/test_order.py @@ -163,6 +163,14 @@ class TestMrpOrder(TestMrpCommon): # check sub product availability state is assigned self.assertEqual(production_2.reservation_state, 'assigned', 'Production order should be availability for assigned state') + @freeze_time('2022-06-28 08:00') + def test_end_date(self): + """ End date must be the day the MO is done (regardless of lead times)""" + mo, bom_id, _p_final, _p1, _p2 = self.generate_mo(qty_base_1=10, qty_final=1, qty_base_2=1) + bom_id.produce_delay = 5 + mo.button_mark_done() + self.assertEqual(mo.date_finished.day, 28) + def test_over_consumption(self): """ Consume more component quantity than the initial demand. No split on moves. """