diff options
| author | Nicolas Galler <ngl@odoo.com> | 2020-12-21 14:32:55 +0000 |
|---|---|---|
| committer | Nicolas Galler <ngl@odoo.com> | 2020-12-31 10:56:10 +0000 |
| commit | 04bbeb79ca6a04dd44f834bfee30af3a36aa497f (patch) | |
| tree | 828162795242a6887683dbe846fa72df2ad81b8e /addons | |
| parent | be5f3bdfe5f593e2f3998f93b98b9f43e1658ee6 (diff) | |
[FIX] mrp: update date on move when editing date after planning WO
Behavior prior to this commit:
- normally when editing the Scheduled Date on a MO, the date on the
related stock moves is updated. However this does not happen once the
MO is planned
- if the date is edited and the MO is planned, the MO is automatically
unplanned, but the date on the stock moves is not automatically updated
Behavior after this commit:
- when the date is updated on the MO and it is planned, the dates on the
stock moves will automatically update, so that the behavior is
consistent with how it would work if you clicked Unplan first then
updated the date.
opw-2417108
closes odoo/odoo#63652
Signed-off-by: Nicolas Galler <ngaller@users.noreply.github.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/mrp/models/mrp_production.py | 2 | ||||
| -rw-r--r-- | addons/mrp/tests/test_order.py | 16 |
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). |
