[MREGE]: Merge with lp:~openerp-commiter/openobject-addons/dev-addons2-rha1
bzr revid: rpa@tinyerp.com-20110214115943-p9ss7bn09sj0ift1
This commit is contained in:
parent
572224f266
commit
e9097e14ac
|
@ -240,10 +240,28 @@ class mrp_bom(osv.osv):
|
|||
return False
|
||||
level -= 1
|
||||
return True
|
||||
_constraints = [
|
||||
(_check_recursion, 'Error ! You can not create recursive BoM.', ['parent_id'])
|
||||
]
|
||||
|
||||
def _check_product(self, cr, uid, ids, context=None):
|
||||
all_prod = []
|
||||
bom_obj = self.pool.get('mrp.bom')
|
||||
boms = self.browse(cr, uid, ids, context=context)
|
||||
def check_bom(boms):
|
||||
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)
|
||||
lines = bom.bom_lines
|
||||
if lines:
|
||||
newboms = [a for a in lines if a not in boms]
|
||||
res = res and check_bom(newboms)
|
||||
return res
|
||||
return check_bom(boms)
|
||||
|
||||
_constraints = [
|
||||
(_check_recursion, 'Error ! You can not create recursive BoM.', ['parent_id']),
|
||||
(_check_product, 'BoM line product should not be same as BoM product.', ['product_id']),
|
||||
]
|
||||
|
||||
def onchange_product_id(self, cr, uid, ids, product_id, name, context=None):
|
||||
""" Changes UoM and name if product_id changes.
|
||||
|
|
Loading…
Reference in New Issue