From 1ace1d9fe69e47e3f4e27b53714ac8644ae40006 Mon Sep 17 00:00:00 2001 From: "uco (OpenERP)" Date: Thu, 22 Apr 2010 16:44:02 +0530 Subject: [PATCH 1/2] [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 @@ - + - + From ab65a9c67cd6c1fac4415711c2e9229744ac7b30 Mon Sep 17 00:00:00 2001 From: "uco (OpenERP)" Date: Fri, 23 Apr 2010 16:40:30 +0530 Subject: [PATCH 2/2] [FIX] mrp: Task ID 583: Fixed bug when printing BoM structure report. bzr revid: uco@tinyerp.co.in-20100423111030-kejyf76lxdwpgrxc --- addons/mrp/mrp.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 7e3bb0c2afc..675c4a73bb0 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -162,9 +162,14 @@ class mrp_bom(osv.osv): """ result = {} bom_obj = self.pool.get('mrp.bom') - bom_parent = bom_obj.browse(cr, uid, context['active_id']) + 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): - if bom_parent.multi_level_bom or bom.id == context['active_id']: + 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] = []