summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/mrp/models/mrp_production.py2
-rw-r--r--addons/mrp/tests/test_order.py16
2 files changed, 18 insertions, 0 deletions
diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py
index 74ee4ccfc45..a8021609da8 100644
--- a/addons/mrp/models/mrp_production.py
+++ b/addons/mrp/models/mrp_production.py
@@ -718,6 +718,8 @@ class MrpProduction(models.Model):
raise UserError(_('You cannot move a manufacturing order once it is cancelled or done.'))
if production.is_planned:
production.button_unplan()
+ move_vals = self._get_move_finished_values(self.product_id, self.product_uom_qty, self.product_uom_id)
+ production.move_finished_ids.write({'date': move_vals['date']})
if vals.get('date_planned_start'):
production.move_raw_ids.write({'date': production.date_planned_start, 'date_deadline': production.date_planned_start})
if vals.get('date_planned_finished'):
diff --git a/addons/mrp/tests/test_order.py b/addons/mrp/tests/test_order.py
index 65a4da48486..e42eb695af8 100644
--- a/addons/mrp/tests/test_order.py
+++ b/addons/mrp/tests/test_order.py
@@ -316,6 +316,22 @@ class TestMrpOrder(TestMrpCommon):
production = mo_form.save()
self.assertEqual(production.workorder_ids.duration_expected, 90)
+ def test_update_plan_date(self):
+ """Editing the scheduled date after planning the MO should unplan the MO, and adjust the date on the stock moves"""
+ planned_date = datetime(2023, 5, 15, 9, 0)
+ mo_form = Form(self.env['mrp.production'])
+ mo_form.product_id = self.product_4
+ mo_form.bom_id = self.bom_1
+ mo_form.product_qty = 1
+ mo_form.date_planned_start = planned_date
+ mo = mo_form.save()
+ self.assertEqual(mo.move_finished_ids[0].date, datetime(2023, 5, 15, 10, 0))
+ mo.action_confirm()
+ mo.button_plan()
+ with Form(mo) as frm:
+ frm.date_planned_start = datetime(2024, 5, 15, 9, 0)
+ self.assertEqual(mo.move_finished_ids[0].date, datetime(2024, 5, 15, 10, 0))
+
def test_rounding(self):
""" Checks we round up when bringing goods to produce and round half-up when producing.
This implementation allows to implement an efficiency notion (see rev 347f140fe63612ee05e).