From ab557cc1e6b57666880f4361b39584c8b3f9ea0e Mon Sep 17 00:00:00 2001 From: "ACH,VRA" <> Date: Mon, 8 Feb 2010 12:56:55 +0530 Subject: [PATCH] [IMP] MRP : BOM structure report should follow hierarchy. bzr revid: jvo@tinyerp.com-20100208072655-f7nndzqb00tg7pm9 --- addons/mrp/report/__init__.py | 1 + addons/mrp/report/bom_structure.py | 64 +++++++++++++++++++++++++++++ addons/mrp/report/bom_structure.rml | 12 +++--- 3 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 addons/mrp/report/bom_structure.py diff --git a/addons/mrp/report/__init__.py b/addons/mrp/report/__init__.py index 4456190cfcb..8b47ad3527e 100644 --- a/addons/mrp/report/__init__.py +++ b/addons/mrp/report/__init__.py @@ -22,6 +22,7 @@ import price import workcenter_load import order +import bom_structure # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mrp/report/bom_structure.py b/addons/mrp/report/bom_structure.py new file mode 100644 index 00000000000..25d179b6901 --- /dev/null +++ b/addons/mrp/report/bom_structure.py @@ -0,0 +1,64 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +import time +from report import report_sxw +from osv import osv +import pooler + +class bom_structure(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context): + super(bom_structure, self).__init__(cr, uid, name, context=context) + self.localcontext.update({ + 'time': time, + 'get_children':self.get_children, + }) + + def get_children(self, object, level=0): + result = [] + + def _get_rec(object,level): + for l in object: + res = {} + res['name'] = l.name + res['pname'] = l.product_id.name + res['pqty'] = l.product_qty + res['uname'] = l.product_uom.name + res['code'] = l.code + res['level'] = level + result.append(res) + if l.child_complete_ids: + if level<6: + level += 1 + _get_rec(l.child_complete_ids,level) + if level>0 and level<6: + level -= 1 + return result + + children = _get_rec(object,level) + + return children + +report_sxw.report_sxw('report.bom.structure','mrp.bom','mrp/report/bom_structure.rml',parser=bom_structure) + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/mrp/report/bom_structure.rml b/addons/mrp/report/bom_structure.rml index 7601e490eec..527c26d1581 100644 --- a/addons/mrp/report/bom_structure.rml +++ b/addons/mrp/report/bom_structure.rml @@ -112,20 +112,20 @@
- [[ repeatIn(o.bom_lines, 'l') ]] + [[ repeatIn(get_children(o.bom_lines), 'l') ]] - - [[ l.name ]] + [[ '... '*(l['level']) ]]-[[ l['name'] ]] - [[ l.product_id.name ]] + [[ l['pname'] ]] - [[ l.product_qty ]] [[ l.product_uom.name ]] + [[ l['pqty'] ]] [[ l['uname'] ]] - [[ l.code ]] + [[ l['code'] ]] @@ -135,4 +135,4 @@
- + \ No newline at end of file