[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) <whe@odoo.com>
Signed-off-by: Walid Hanniche (waha) <waha@odoo.com>
This commit is contained in:
Walid
2023-10-11 18:03:35 +00:00
parent 7202a632ca
commit ad0555abbe
+8
View File
@@ -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.
"""