summaryrefslogtreecommitdiff
path: root/addons/mrp/tests/test_workorder_operation.py
diff options
context:
space:
mode:
authorWilliam Henrotin <whe@odoo.com>2020-01-29 16:16:40 +0000
committerWilliam Henrotin <whe@odoo.com>2020-01-30 09:47:22 +0000
commitec0d5b488245642a9771cf2db0097cfe594d35fc (patch)
tree6c53542d9798261a3cdb828d649ad5ae0454482a /addons/mrp/tests/test_workorder_operation.py
parent96b17a82cf1ea1287e0a52c52c78166ef817ce7b (diff)
[IMP] mrp: choose operation to consume new product
This commit adds the possibility to choose in which operation a new product will be consumed. New product can be added to the production once the manufacturing order is in state draft. Before this commit, the new product was consumed automatically in the last workorder. Task: 2121714
Diffstat (limited to 'addons/mrp/tests/test_workorder_operation.py')
-rw-r--r--addons/mrp/tests/test_workorder_operation.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/addons/mrp/tests/test_workorder_operation.py b/addons/mrp/tests/test_workorder_operation.py
index 3f4359e2f0b..a40de34a204 100644
--- a/addons/mrp/tests/test_workorder_operation.py
+++ b/addons/mrp/tests/test_workorder_operation.py
@@ -1758,3 +1758,36 @@ class TestRoutingAndKits(SavepointCase):
wo2.button_start()
self.assertEqual(wo2.qty_producing, 10)
self.assertEqual(wo2.finished_lot_id, lot1)
+
+ def test_add_move(self):
+ """ Make a production using multi step routing. Add an additional move
+ on a specific operation and check that the produce is consumed into the
+ right workorder. """
+ self.bom_finished1.consumption = 'flexible'
+ add_product = self.env['product.product'].create({
+ 'name': 'Additional',
+ })
+ mo_form = Form(self.env['mrp.production'])
+ mo_form.product_id = self.finished1
+ mo_form.bom_id = self.bom_finished1
+ mo_form.product_qty = 10.0
+ mo = mo_form.save()
+
+ mo_form = Form(mo)
+ with mo_form.move_raw_ids.new() as move:
+ move.name = mo.name
+ move.product_id = add_product
+ move.product_uom = add_product.uom_id
+ move.location_id = mo.location_src_id
+ move.location_dest_id = mo.production_location_id
+ move.product_uom_qty = 2
+ move.operation_id = mo.routing_id.operation_ids[0]
+ mo = mo_form.save()
+ self.assertEqual(len(mo.move_raw_ids), 3)
+ mo.action_confirm()
+ self.assertEqual(mo.move_raw_ids.mapped('state'), ['confirmed'] * 3)
+ mo.button_plan()
+ self.assertEqual(len(mo.workorder_ids), 3)
+ wo1 = mo.workorder_ids[0]
+ lines = wo1.raw_workorder_line_ids
+ self.assertEqual(lines.product_id, add_product)