Skip to content
Permalink
Browse files

[FIX] mrp: missing default uom

purpose: on a MO, producing via the 'Produce' wizard give the ability to add any additionnal product into the production. 
The issue is that the UoM of the new line is empty and so will trigger an error later in the flow. 
This commit add a new onchange on product_id to ensure the field product_uom_id will be set accordingly

closes #31950

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
  • Loading branch information...
Whenrow committed Mar 19, 2019
1 parent 04370bf commit 9c53a141dcecf9646e8ddba42ffca34b4b593b69
Showing with 8 additions and 0 deletions.
  1. +5 −0 addons/mrp/models/mrp_abstract_workorder.py
  2. +3 −0 addons/mrp/tests/test_order.py
@@ -249,6 +249,11 @@ def _onchange_lot_id(self):
if self.product_id.tracking == 'serial':
self.qty_done = 1

@api.onchange('product_id')
def _onchange_product_id(self):
if self.product_id and not self.move_id:
self.product_uom_id = self.product_id.uom_id

@api.onchange('qty_done')
def _onchange_qty_done(self):
""" When the user is encoding a produce line for a tracked product, we apply some logic to
@@ -706,6 +706,9 @@ def test_product_produce_6(self):
self.assertEqual(len(produce_form.workorder_line_ids._records), 2, 'Update the produce quantity should change the components quantity.')
self.assertEqual(sum([x['qty_done'] for x in produce_form.workorder_line_ids._records]), 5, 'Update the produce quantity should change the components quantity.')
self.assertEqual(sum([x['qty_reserved'] for x in produce_form.workorder_line_ids._records]), 5, 'Update the produce quantity should not change the components reserved quantity.')
# try adding another product that doesn't belong to the BoM
with produce_form.workorder_line_ids.new() as line:
line.product_id = self.product_4
produce_wizard = produce_form.save()
produce_wizard.do_produce()

0 comments on commit 9c53a14

Please sign in to comment.
You can’t perform that action at this time.