From 4d429a10f2255d220528aa8207a0ea456ba24e85 Mon Sep 17 00:00:00 2001 From: "Adrien Widart (awt)" Date: Thu, 14 Sep 2023 11:53:46 +0000 Subject: [PATCH] [FIX] mrp: edit to-consume qty on confirmed MO When adding a new raw SM to a confirmed and locked MO, it should still be possible for the user to define the to-consume quantity (else, he would have to unlock the MO and only then to edit the new line) OPW-3253204 closes odoo/odoo#136009 X-original-commit: b78c468317079ac415d7b1fdbd4d4d081ff3976b Signed-off-by: William Henrotin (whe) Signed-off-by: Djamel Touati (otd) --- addons/mrp/tests/test_procurement.py | 35 +++++++++++++++++++++++ addons/mrp/views/mrp_production_views.xml | 4 +-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/addons/mrp/tests/test_procurement.py b/addons/mrp/tests/test_procurement.py index ac29dddd61e..9a511ff4bed 100644 --- a/addons/mrp/tests/test_procurement.py +++ b/addons/mrp/tests/test_procurement.py @@ -881,3 +881,38 @@ class TestProcurement(TestMrpCommon): # comp2 (2 + 4 extra) = 6 # comp3 (2 + 2 extra) = 4 self.assertEqual(mo.picking_ids[0].move_ids.mapped('product_uom_qty'), [5, 6, 4], 'Comp qty do not match expected') + + def test_pbm_and_additionnal_components(self): + """ + 2-steps manufacturring. + When adding a new component to a confirmed MO, it should add an SM in + the PBM picking. Also, it should be possible to define the to-consume + qty of the new line even if the MO is locked + """ + warehouse = self.env['stock.warehouse'].search([('company_id', '=', self.env.company.id)], limit=1) + warehouse.manufacture_steps = 'pbm' + + mo_form = Form(self.env['mrp.production']) + mo_form.bom_id = self.bom_4 + mo = mo_form.save() + mo.action_confirm() + + if not mo.is_locked: + mo.action_toggle_is_locked() + + with Form(mo) as mo_form: + with mo_form.move_raw_ids.new() as raw_line: + raw_line.product_id = self.product_2 + raw_line.product_uom_qty = 2.0 + + move_vals = mo._get_move_raw_values(self.product_3, 0, self.product_3.uom_id) + mo.move_raw_ids = [(0, 0, move_vals)] + mo.move_raw_ids[-1].product_uom_qty = 3.0 + + expected_vals = [ + {'product_id': self.product_1.id, 'product_uom_qty': 1.0}, + {'product_id': self.product_2.id, 'product_uom_qty': 2.0}, + {'product_id': self.product_3.id, 'product_uom_qty': 3.0}, + ] + self.assertRecordValues(mo.move_raw_ids, expected_vals) + self.assertRecordValues(mo.picking_ids.move_ids, expected_vals) diff --git a/addons/mrp/views/mrp_production_views.xml b/addons/mrp/views/mrp_production_views.xml index 00c3196f67f..580b2b0bd8f 100644 --- a/addons/mrp/views/mrp_production_views.xml +++ b/addons/mrp/views/mrp_production_views.xml @@ -372,8 +372,8 @@ - - + +