diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py
index 429a3497634..675c4a73bb0 100644
--- a/addons/mrp/mrp.py
+++ b/addons/mrp/mrp.py
@@ -162,16 +162,25 @@ class mrp_bom(osv.osv):
"""
result = {}
bom_obj = self.pool.get('mrp.bom')
+ bom_id = context and context.get('active_id', False) or False
+ cr.execute('select id from mrp_bom')
+ if all(bom_id != r[0] for r in cr.fetchall()):
+ ids.sort()
+ bom_id = ids[0]
+ bom_parent = bom_obj.browse(cr, uid, bom_id)
for bom in self.browse(cr, uid, ids, context=context):
- result[bom.id] = map(lambda x: x.id, bom.bom_lines)
+ if (bom_parent and bom_parent.multi_level_bom) or bom.id == bom_id:
+ result[bom.id] = map(lambda x: x.id, bom.bom_lines)
+ else:
+ result[bom.id] = []
if bom.bom_lines:
continue
ok = ((name=='child_complete_ids') and (bom.product_id.supply_method=='produce'))
- if bom.type=='phantom' or ok:
+ if (bom.type=='phantom' or ok) and bom_parent.multi_level_bom:
sids = bom_obj.search(cr, uid, [('bom_id','=',False),('product_id','=',bom.product_id.id)])
if sids:
bom2 = bom_obj.browse(cr, uid, sids[0], context=context)
- result[bom.id] += map(lambda x: x.id, bom2.bom_lines)
+ result[bom.id] += map(lambda x: x.id, bom2.bom_lines)
return result
@@ -267,7 +276,7 @@ class mrp_bom(osv.osv):
v['name'] = prod.name
return {'value': v}
return {}
-
+
def _bom_find(self, cr, uid, product_id, product_uom, properties=[]):
""" Finds BoM for particular product and product uom.
@param product_id: Selected product.
diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml
index 6e7a1afb6dc..2c33f69d577 100644
--- a/addons/mrp/mrp_view.xml
+++ b/addons/mrp/mrp_view.xml
@@ -253,13 +253,13 @@
-
+
-
+