From 1ace1d9fe69e47e3f4e27b53714ac8644ae40006 Mon Sep 17 00:00:00 2001 From: "uco (OpenERP)" Date: Thu, 22 Apr 2010 16:44:02 +0530 Subject: [PATCH] [IMP] mrp: Task ID-583 : Added a checkbox that set visible/invisible the bom_lines. The first level is always visible (no checkbox). For the other levels it's visible according to the multi_level_bom field. bzr revid: uco@tinyerp.co.in-20100422111402-eqmxft9rgtpg1d5f --- addons/mrp/mrp.py | 12 ++++++++---- addons/mrp/mrp_view.xml | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 429a3497634..7e3bb0c2afc 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -162,16 +162,20 @@ class mrp_bom(osv.osv): """ result = {} bom_obj = self.pool.get('mrp.bom') + bom_parent = bom_obj.browse(cr, uid, context['active_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.multi_level_bom or bom.id == context['active_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 +271,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 @@ - + - +