[IMP] MRP : BOM structure report should follow hierarchy.
bzr revid: jvo@tinyerp.com-20100208072655-f7nndzqb00tg7pm9
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
import price
|
||||
import workcenter_load
|
||||
import order
|
||||
import bom_structure
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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:
|
||||
@@ -112,20 +112,20 @@
|
||||
</tr>
|
||||
</blockTable>
|
||||
<section>
|
||||
<para style="terp_default_9">[[ repeatIn(o.bom_lines, 'l') ]]</para>
|
||||
<para style="terp_default_9">[[ repeatIn(get_children(o.bom_lines), 'l') ]]</para>
|
||||
<blockTable colWidths="166.0,208.0,79.0,55.0" style="Table1">
|
||||
<tr>
|
||||
<td>
|
||||
<para style="P1">- [[ l.name ]]</para>
|
||||
<para style="P1"><font color="white">[[ '... '*(l['level']) ]]</font>-[[ l['name'] ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P1">[[ l.product_id.name ]]</para>
|
||||
<para style="P1">[[ l['pname'] ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="P2">[[ l.product_qty ]] [[ l.product_uom.name ]]</para>
|
||||
<para style="P2">[[ l['pqty'] ]] [[ l['uname'] ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Centre_9">[[ l.code ]]</para>
|
||||
<para style="terp_default_Centre_9">[[ l['code'] ]]</para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
@@ -135,4 +135,4 @@
|
||||
</section>
|
||||
</section>
|
||||
</story>
|
||||
</document>
|
||||
</document>
|
||||
Reference in New Issue
Block a user