[IMP] Converted mrp BOM Structure to QWeb
bzr revid: sle@openerp.com-20140224103453-0s60blgbk7e3ho5n
This commit is contained in:
parent
09d34a8e96
commit
62538c61e3
|
@ -74,6 +74,7 @@ Dashboard / Reports for MRP will include:
|
|||
'res_config_view.xml',
|
||||
|
||||
'views/report_mrporder.xml',
|
||||
'views/report_mrpbomstructure.xml',
|
||||
],
|
||||
'demo': ['mrp_demo.xml'],
|
||||
#TODO: This yml tests are needed to be completely reviewed again because the product wood panel is removed in product demo as it does not suit for new demo context of computer and consultant company
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<report auto="True" header="False" id="report_bom_structure" model="mrp.bom" name="bom.structure" rml="mrp/report/bom_structure.rml" string="BOM Structure"/>
|
||||
<report
|
||||
string="BOM Structure"
|
||||
id="action_report_bom_structure"
|
||||
model="mrp.bom"
|
||||
name="mrp.report_mrpbomstructure"
|
||||
file="mrp.report_mrpbomstructure"
|
||||
report_type="qweb-pdf"
|
||||
/>
|
||||
|
||||
<report
|
||||
string="Production Order"
|
||||
|
@ -18,6 +24,7 @@
|
|||
menu="False"
|
||||
name="product.price"
|
||||
string="Cost Structure"
|
||||
xsl="mrp/report/price.xsl"/>
|
||||
xsl="mrp/report/price.xsl"
|
||||
/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -19,16 +19,24 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
from openerp.report import report_sxw
|
||||
from openerp.addons.web import http
|
||||
from openerp.addons.web.http import request
|
||||
|
||||
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,
|
||||
})
|
||||
|
||||
class bom_structure(http.Controller):
|
||||
|
||||
@http.route(['/report/mrp.report_mrpbomstructure/<docids>'], type='http', auth='user', website=True, multilang=True)
|
||||
def report_mrpbomstructure(self, docids):
|
||||
ids = [int(i) for i in docids.split(',')]
|
||||
ids = list(set(ids))
|
||||
report_obj = request.registry['mrp.bom']
|
||||
docs = report_obj.browse(request.cr, request.uid, ids, context=request.context)
|
||||
|
||||
docargs = {
|
||||
'docs': docs,
|
||||
'get_children': self.get_children,
|
||||
}
|
||||
return request.registry['report'].render(request.cr, request.uid, [], 'mrp.report_mrpbomstructure', docargs)
|
||||
|
||||
def get_children(self, object, level=0):
|
||||
result = []
|
||||
|
@ -56,7 +64,4 @@ class bom_structure(report_sxw.rml_parse):
|
|||
|
||||
return children
|
||||
|
||||
report_sxw.report_sxw('report.bom.structure','mrp.bom','mrp/report/bom_structure.rml',parser=bom_structure,header='internal')
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -1,154 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<document filename="BOM Structure.pdf">
|
||||
<template title="BOM Structure" author="OpenERP S.A.(sales@openerp.com)" allowSplitting="20">
|
||||
<pageTemplate id="first">
|
||||
<frame id="first" x1="31.0" y1="30.0" width="532" height="781"/>
|
||||
</pageTemplate>
|
||||
</template>
|
||||
<stylesheet>
|
||||
<blockTableStyle id="Standard_Outline">
|
||||
<blockAlignment value="LEFT"/>
|
||||
<blockValign value="TOP"/>
|
||||
</blockTableStyle>
|
||||
<blockTableStyle id="Table2">
|
||||
<blockAlignment value="LEFT"/>
|
||||
<blockValign value="TOP"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/>
|
||||
</blockTableStyle>
|
||||
<blockTableStyle id="Table1">
|
||||
<blockAlignment value="LEFT"/>
|
||||
<blockValign value="TOP"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#999999" start="0,-1" stop="0,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#999999" start="1,-1" stop="1,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#999999" start="2,-1" stop="2,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#999999" start="3,-1" stop="3,-1"/>
|
||||
</blockTableStyle>
|
||||
<blockTableStyle id="Table3">
|
||||
<blockAlignment value="LEFT"/>
|
||||
<blockValign value="TOP"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,-1" stop="0,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/>
|
||||
</blockTableStyle>
|
||||
<initialize>
|
||||
<paraStyle name="all" alignment="justify"/>
|
||||
</initialize>
|
||||
<paraStyle name="Standard" fontName="Helvetica"/>
|
||||
<paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Caption" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Index" fontName="Helvetica"/>
|
||||
<paraStyle name="Table Contents" fontName="Helvetica" fontSize="6.0" leading="8" alignment="LEFT"/>
|
||||
<paraStyle name="Table Heading" fontName="Helvetica" fontSize="6.0" leading="8" alignment="CENTER"/>
|
||||
<paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
|
||||
<paraStyle name="terp_default_Bold_8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
|
||||
<paraStyle name="terp_default_Bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
|
||||
<paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
|
||||
<paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
|
||||
<paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Footer" fontName="Helvetica"/>
|
||||
<paraStyle name="Horizontal Line" fontName="Helvetica" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/>
|
||||
<paraStyle name="Heading 9" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="terp_tblheader_General_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="terp_tblheader_Details_Centre" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="terp_tblheader_Details_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="terp_default_Right_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
|
||||
<paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
|
||||
<paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
|
||||
<paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
|
||||
<paraStyle name="terp_default_1" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
|
||||
<paraStyle name="terp_default_Right_9_Bold" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
|
||||
<paraStyle name="terp_default_8_Italic" fontName="Helvetica-Oblique" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
|
||||
<paraStyle name="Heading 2" fontName="Helvetica-BoldOblique" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="terp_remove_space" fontName="Helvetica" fontSize="2.0" leading="3" spaceBefore="0.0" spaceAfter="0.0"/>
|
||||
<images/>
|
||||
</stylesheet>
|
||||
<story>
|
||||
<pto>
|
||||
<pto_header>
|
||||
<blockTable colWidths="192.0,198.0,71.0,71.0" style="Table2">
|
||||
<tr>
|
||||
<td>
|
||||
<para style="terp_tblheader_Details">BOM Name</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_tblheader_Details">Product Name</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_tblheader_Details_Right">Quantity</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_tblheader_General_Centre">BOM Ref</para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
</pto_header>
|
||||
|
||||
<para style="terp_header_Centre">BOM Structure</para>
|
||||
<blockTable colWidths="192.0,198.0,71.0,71.0" style="Table2">
|
||||
<tr>
|
||||
<td>
|
||||
<para style="terp_tblheader_Details">BOM Name</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_tblheader_Details">Product Name</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_tblheader_Details_Right">Quantity</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_tblheader_General_Centre">BOM Ref</para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
<section>
|
||||
<para style="terp_default_8">[[ repeatIn(objects, 'o') ]]</para>
|
||||
<blockTable colWidths="192.0,198.0,71.0,71.0" style="Table1">
|
||||
<tr>
|
||||
<td>
|
||||
<para style="terp_default_Bold_9">[[ o.name ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Bold_9">[ [[ (o.product_id.default_code) or removeParentNode('font') ]] ] [[ o.product_id.name ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Right_9_Bold">[[ o.product_qty ]] [[ o.product_uom.name ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_tblheader_Details_Centre">[[ o.code ]]</para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
<section>
|
||||
<para style="terp_default_8">[[ repeatIn(get_children(o.bom_lines), 'l') ]]</para>
|
||||
<blockTable colWidths="192.0,198.0,71.0,71.0" style="Table3">
|
||||
<tr>
|
||||
<td>
|
||||
<para style="terp_default_9"><font face="Helvetica" size="8.0" color="white">[[ '... '*(l['level']) ]]</font> - [[ l['name'] ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_9">[ [[ (l['pcode']) or removeParentNode('font') ]] ] [[ l['pname'] ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Right_9">[[ l['pqty'] ]] [[ l['uname'] ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Centre_9">[[ l['code'] ]]</para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
</section>
|
||||
</section>
|
||||
</pto>
|
||||
</story>
|
||||
</document>
|
|
@ -224,20 +224,6 @@
|
|||
assert line.journal_id.id == wc.costs_journal_id.id, "Account Journal is not correspond."
|
||||
assert line.product_id.id == wc.product_id.id, "Product is not correspond."
|
||||
assert line.product_uom_id.id == wc.product_id.uom_id.id, "UOM is not correspond."
|
||||
-
|
||||
I print a "BOM Structure".
|
||||
-
|
||||
!context
|
||||
uid: 'res_users_mrp_user'
|
||||
-
|
||||
!python {model: mrp.production}: |
|
||||
import os
|
||||
import openerp.report
|
||||
from openerp import tools
|
||||
order = self.browse(cr, uid, ref("mrp_production_test1"))
|
||||
data, format = openerp.report.render_report(cr, uid, [order.bom_id.id], 'bom.structure', {}, {})
|
||||
if tools.config['test_report_directory']:
|
||||
file(os.path.join(tools.config['test_report_directory'], 'mrp-bom_structure_report.'+format), 'wb+').write(data)
|
||||
-
|
||||
I print "Work Center Load Report".
|
||||
-
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<template id="report_mrpbomstructure">
|
||||
<t t-call="report.html_container">
|
||||
<t t-call="report.internal_layout">
|
||||
<div class="page">
|
||||
<h2>BOM Structure</h2>
|
||||
|
||||
<table class="table table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>BOM Name</th>
|
||||
<th>Product Name</th>
|
||||
<th>Quantity</th>
|
||||
<th>BOM Ref</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-foreach="docs" t-as="o">
|
||||
<tr style="font-weight: bold;">
|
||||
<td><span t-field="o.name"/></td>
|
||||
<td><span t-field="o.product_id.default_code"/><span t-field="o.product_id.name"/></td>
|
||||
<td>
|
||||
<span t-field="o.product_qty"/>
|
||||
<span groups="product.group_uom" t-field="o.product_uom.name"/>
|
||||
</td>
|
||||
<td><span t-field="o.code"/></td>
|
||||
</tr>
|
||||
<tr t-foreach="get_children(o.bom_lines)" t-as="l">
|
||||
<td>
|
||||
<span style="color: white;" t-esc="'... '*(l['level'])"/>
|
||||
- <span t-esc="l['name']"/>
|
||||
</td>
|
||||
<td>
|
||||
[ <span t-esc="l['pcode']"/> ]
|
||||
<span t-esc="l['pname']"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-esc="formatLang(l['pqty'])"/>
|
||||
<span t-esc="l['uname']" groups="product.group_uom"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-esc="l['code']"/>
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue