Skip to content

Commit

Permalink
[FIX] mrp: Test recursive BOM
Browse files Browse the repository at this point in the history
Test that detects a recursion in BOM when exploding.

opw:745453
  • Loading branch information
simongoffin committed Jun 20, 2017
1 parent 52e0540 commit 2bf5d1a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
20 changes: 10 additions & 10 deletions addons/mrp/tests/test_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,28 +133,28 @@ def test_multi_level_variants(self):

#check recursion
test_bom_3 = self.env['mrp.bom'].create({
'product_id': self.product_2.id,
'product_tmpl_id': self.product_2.product_tmpl_id.id,
'product_uom_id': self.product_2.uom_id.id,
'product_id': self.product_9.id,
'product_tmpl_id': self.product_9.product_tmpl_id.id,
'product_uom_id': self.product_9.uom_id.id,
'product_qty': 1.0,
'type': 'normal'
})
test_bom_4 = self.env['mrp.bom'].create({
'product_id': self.product_4.id,
'product_tmpl_id': self.product_4.product_tmpl_id.id,
'product_uom_id': self.product_4.uom_id.id,
'product_id': self.product_10.id,
'product_tmpl_id': self.product_10.product_tmpl_id.id,
'product_uom_id': self.product_10.uom_id.id,
'product_qty': 1.0,
'type': 'phantom'
})
test_bom_3_l1 = self.env['mrp.bom.line'].create({
'bom_id': test_bom_3.id,
'product_id': self.product_4.id,
'product_id': self.product_10.id,
'product_qty': 1.0,
})
test_bom_4_l1 = self.env['mrp.bom.line'].create({
'bom_id': test_bom_4.id,
'product_id': self.product_2.id,
'product_id': self.product_9.id,
'product_qty': 1.0,
})
# with self.assertRaises(exceptions.UserError):
# test_bom_3.explode(self.product_2, 1)
with self.assertRaises(exceptions.UserError):
test_bom_3.explode(self.product_9, 1)
10 changes: 10 additions & 0 deletions addons/product/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,13 @@ def setUpClass(cls):
'name': 'House',
'uom_id': cls.uom_unit.id,
'uom_po_id': cls.uom_unit.id})

cls.product_9 = Product.create({
'name': 'Paper',
'uom_id': cls.uom_unit.id,
'uom_po_id': cls.uom_unit.id})

cls.product_10 = Product.create({
'name': 'Stone',
'uom_id': cls.uom_unit.id,
'uom_po_id': cls.uom_unit.id})

0 comments on commit 2bf5d1a

Please sign in to comment.