summaryrefslogtreecommitdiff
path: root/addons/mrp/tests/test_order.py
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2019-11-04 16:37:01 +0100
committerYannick Tivisse <yti@odoo.com>2019-11-05 13:08:03 +0100
commit14a6fc9ce90d789e0d7e6ea64dcfe2d896834faf (patch)
treefc741e960e4631b8826d4939582d17cb5a0184ef /addons/mrp/tests/test_order.py
parentca32dd2bda751867e4c56008947dcf95115f0f26 (diff)
[IMP] mrp: Adapt tests to work with/without demo data
Diffstat (limited to 'addons/mrp/tests/test_order.py')
-rw-r--r--addons/mrp/tests/test_order.py61
1 files changed, 45 insertions, 16 deletions
diff --git a/addons/mrp/tests/test_order.py b/addons/mrp/tests/test_order.py
index 3cd315da16b..c7d06af6aea 100644
--- a/addons/mrp/tests/test_order.py
+++ b/addons/mrp/tests/test_order.py
@@ -131,7 +131,7 @@ class TestMrpOrder(TestMrpCommon):
self.env['stock.quant'].with_context(inventory_mode=True).create({
'product_id': self.product_2.id,
'inventory_quantity': 2.0,
- 'location_id': self.ref('stock.stock_location_14')
+ 'location_id': self.stock_location_14.id
})
production_2.action_assign()
@@ -142,7 +142,7 @@ class TestMrpOrder(TestMrpCommon):
self.env['stock.quant'].with_context(inventory_mode=True).create({
'product_id': self.product_2.id,
'inventory_quantity': 5.0,
- 'location_id': self.ref('stock.stock_location_14')
+ 'location_id': self.stock_location_14.id
})
production_2.action_assign()
@@ -163,8 +163,13 @@ class TestMrpOrder(TestMrpCommon):
# create a bom for `custom_laptop` with components that aren't tracked
unit = self.ref("uom.product_uom_unit")
- custom_laptop = self.env.ref("product.product_product_27")
- custom_laptop.tracking = 'none'
+ custom_laptop = self.env['product.product'].create({
+ 'name': 'Drawer',
+ 'type': 'product',
+ 'uom_id': unit,
+ 'uom_po_id': unit,
+ })
+
product_charger = self.env['product.product'].create({
'name': 'Charger',
'type': 'product',
@@ -191,7 +196,7 @@ class TestMrpOrder(TestMrpCommon):
})
# put the needed products in stock
- source_location_id = self.ref('stock.stock_location_14')
+ source_location_id = self.stock_location_14.id
quant_before = custom_laptop.qty_available
inventory = self.env['stock.inventory'].create({
'name': 'Inventory Product Table',
@@ -463,8 +468,9 @@ class TestMrpOrder(TestMrpCommon):
"""
# FIXME: some asserts on the quants after overproducing would be nice
self.stock_location = self.env.ref('stock.stock_location_stock')
- self.stock_shelf_1 = self.env.ref('stock.stock_location_components')
- self.stock_shelf_2 = self.env.ref('stock.stock_location_14')
+ self.stock_shelf_1 = self.stock_location_components
+
+ self.stock_shelf_2 = self.stock_location_14
mo, _, p_final, p1, p2 = self.generate_mo(tracking_base_1='lot', qty_base_1=10, qty_final=1)
self.assertEqual(len(mo), 1, 'MO should have been created')
@@ -530,8 +536,8 @@ class TestMrpOrder(TestMrpCommon):
""" Possibility to produce with a given raw material in multiple locations. """
# FIXME sle: how is it possible to consume before producing in the interface?
self.stock_location = self.env.ref('stock.stock_location_stock')
- self.stock_shelf_1 = self.env.ref('stock.stock_location_components')
- self.stock_shelf_2 = self.env.ref('stock.stock_location_14')
+ self.stock_shelf_1 = self.stock_location_components
+ self.stock_shelf_2 = self.stock_location_14
mo, _, p_final, p1, p2 = self.generate_mo(qty_final=1, qty_base_1=5)
self.env['stock.quant']._update_available_quantity(p1, self.stock_shelf_1, 2)
@@ -616,8 +622,8 @@ class TestMrpOrder(TestMrpCommon):
self.assertEqual(len(mo), 1, 'MO should have been created')
self.stock_location = self.env.ref('stock.stock_location_stock')
- self.stock_shelf_1 = self.env.ref('stock.stock_location_components')
- self.stock_shelf_2 = self.env.ref('stock.stock_location_14')
+ self.stock_shelf_1 = self.stock_location_components
+ self.stock_shelf_2 = self.stock_location_14
self.env['stock.quant']._update_available_quantity(p1, self.stock_shelf_1, 3)
self.env['stock.quant']._update_available_quantity(p1, self.stock_location, 3)
@@ -1146,13 +1152,36 @@ class TestMrpOrder(TestMrpCommon):
""" Produce a finished product tracked by serial number. Set another
UoM on the bom. The produce wizard should keep the UoM of the product (unit)
and quantity = 1."""
-
- plastic_laminate = self.env.ref('mrp.product_product_plastic_laminate')
- bom = self.env.ref('mrp.mrp_bom_plastic_laminate')
dozen = self.env.ref('uom.product_uom_dozen')
unit = self.env.ref('uom.product_uom_unit')
-
- plastic_laminate.tracking = 'serial'
+ plastic_laminate = self.env['product.product'].create({
+ 'name': 'Plastic Laminate',
+ 'type': 'product',
+ 'uom_id': unit.id,
+ 'uom_po_id': unit.id,
+ 'tracking': 'serial',
+ })
+ ply_veneer = self.env['product.product'].create({
+ 'name': 'Ply Veneer',
+ 'type': 'product',
+ 'uom_id': unit.id,
+ 'uom_po_id': unit.id,
+ })
+ routing = self.env['mrp.routing'].create({
+ 'name': 'Secondary Assembly',
+ })
+ bom = self.env['mrp.bom'].create({
+ 'product_tmpl_id': plastic_laminate.product_tmpl_id.id,
+ 'product_uom_id': unit.id,
+ 'sequence': 1,
+ 'routing_id': routing.id,
+ 'bom_line_ids': [(0, 0, {
+ 'product_id': ply_veneer.id,
+ 'product_qty': 1,
+ 'product_uom_id': unit.id,
+ 'sequence': 1,
+ })]
+ })
mo_form = Form(self.env['mrp.production'])
mo_form.product_id = plastic_laminate