[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) <whe@odoo.com> Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
This commit is contained in:
committed by
Djamel Touati
parent
d2e771b1fb
commit
4d429a10f2
@@ -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)
|
||||
|
||||
@@ -372,8 +372,8 @@
|
||||
<field name="location_dest_id" domain="[('id', 'child_of', parent.location_dest_id)]" column_invisible="True"/>
|
||||
<field name="state" column_invisible="True" force_save="1"/>
|
||||
<field name="should_consume_qty" column_invisible="True"/>
|
||||
<field name="product_uom_qty" force_save="1" string="To Consume" column_invisible="not parent.show_produce_all" readonly="parent.state != 'draft' and ((parent.state not in ('confirmed', 'progress', 'to_close') and not parent.is_planned) or parent.is_locked)"/>
|
||||
<field name="product_uom_qty" widget="mrp_should_consume" force_save="1" string="To Consume" column_invisible="parent.show_produce_all" readonly="parent.state != 'draft' and ((parent.state not in ('confirmed', 'progress', 'to_close') and not parent.is_planned) or parent.is_locked)"/>
|
||||
<field name="product_uom_qty" force_save="1" string="To Consume" column_invisible="not parent.show_produce_all" readonly="parent.state != 'draft' and ((parent.state not in ('confirmed', 'progress', 'to_close') and not parent.is_planned) or (parent.is_locked and state != 'draft'))"/>
|
||||
<field name="product_uom_qty" widget="mrp_should_consume" force_save="1" string="To Consume" column_invisible="parent.show_produce_all" readonly="parent.state != 'draft' and ((parent.state not in ('confirmed', 'progress', 'to_close') and not parent.is_planned) or (parent.is_locked and state != 'draft'))"/>
|
||||
<field name="product_uom" readonly="state != 'draft' and id" options="{'no_open': True, 'no_create': True}" groups="uom.group_uom"/>
|
||||
<field name="product_type" column_invisible="True"/>
|
||||
<field name="product_qty" readonly="1" column_invisible="True"/>
|
||||
|
||||
Reference in New Issue
Block a user