Skip to content

Commit

Permalink
[MRG] [FIX] don't include adjacent bom's products into check for recu…
Browse files Browse the repository at this point in the history
…rsion (closes lp:1155569)

https://launchpad.net/bugs/1155569
  • Loading branch information
hbrunn authored and Stefan Rijnhart committed Jul 2, 2014
1 parent e027cea commit 3ec0353
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions addons/mrp/mrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,19 +247,17 @@ def _check_recursion(self, cr, uid, ids, context=None):
return True

def _check_product(self, cr, uid, ids, context=None):
all_prod = []
boms = self.browse(cr, uid, ids, context=context)
def check_bom(boms):
def check_bom(boms, all_prod):
res = True
for bom in boms:
if bom.product_id.id in all_prod:
res = res and False
all_prod.append(bom.product_id.id)
return False
lines = bom.bom_lines
if lines:
res = res and check_bom([bom_id for bom_id in lines if bom_id not in boms])
res = res and check_bom([bom_id for bom_id in lines if bom_id not in boms], all_prod + [bom.product_id.id])
return res
return check_bom(boms)
return check_bom(boms, [])

_constraints = [
(_check_recursion, 'Error ! You cannot create recursive BoM.', ['parent_id']),
Expand Down

0 comments on commit 3ec0353

Please sign in to comment.