[IMP] mrp_operations : Convert mrp_wc_barcode.rml to qweb report. Set custom paperformat height and width. Also Improve yml test case

This commit is contained in:
Jaydeep Barot
2015-02-04 15:28:50 +01:00
committed by Damien Bouvy
parent e4f44f9d54
commit ea7cc4bf86
8 changed files with 49 additions and 77 deletions
+2
View File
@@ -56,12 +56,14 @@ So, that we can compare the theoretic delay and real delay.
'website': 'https://www.odoo.com/page/manufacturing',
'depends': ['mrp'],
'data': [
'data/report_paperformat.xml',
'security/ir.model.access.csv',
'mrp_operation_data.xml',
'mrp_operations_workflow.xml',
'mrp_operations_view.xml',
'mrp_operations_report.xml',
'report/mrp_workorder_analysis_view.xml',
'views/report_wcbarcode.xml',
'mrp_operations_workflow_instance.xml'
],
'demo': [
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="paperformat_wcbarcode" model="report.paperformat">
<field name="name">WorkCenter BarCode</field>
<field name="default" eval="True"/>
<field name="format">custom</field>
<field name="page_height">195</field>
<field name="page_width">100</field>
<field name="orientation">Landscape</field>
<field name="margin_top">15</field>
<field name="margin_bottom">0</field>
<field name="margin_left">7</field>
<field name="margin_right">7</field>
<field name="header_line" eval="False"/>
<field name="header_spacing">35</field>
<field name="dpi">90</field>
</record>
</data>
</openerp>
@@ -6,8 +6,9 @@
id="report_wc_barcode"
string="Work Centers Barcode"
model="mrp.workcenter"
name="mrp.wc.barcode"
rml="mrp_operations/report/mrp_wc_barcode.rml"
report_type="qweb-pdf"
file="mrp_operations.report_wcbarcode"
name="mrp_operations.report_wcbarcode"
header="False" />
<report
@@ -18,5 +19,9 @@
rml="mrp_operations/report/mrp_code_barcode.rml"
header="False"/>
<record id="report_wc_barcode" model="ir.actions.report.xml">
<field name="paperformat_id" ref="mrp_operations.paperformat_wcbarcode"/>
</record>
</data>
</openerp>
-1
View File
@@ -19,6 +19,5 @@
#
##############################################################################
import mrp_wc_barcode
import mrp_code_barcode
import mrp_workorder_analysis
@@ -1,31 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from openerp.report import report_sxw
class workcenter_code(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(workcenter_code, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
})
report_sxw.report_sxw('report.mrp.wc.barcode', 'mrp.workcenter', 'addons/mrp_operations/report/mrp_wc_barcode.rml',parser=workcenter_code,header=False)
@@ -1,42 +0,0 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(550,280)" title="WC" author="Odoo (sales@odoo.com)" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="0.1cm" y1="0.1cm" width="530" height="240"/>
</pageTemplate>
</template>
<stylesheet>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<blockTableStyle id="Tableau1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
<blockBackground colorName="#cccccc" start="0,0" stop="0,0"/>
</blockTableStyle>
<paraStyle name="P1" fontName="Times-Roman" fontSize="6.0" leading="8" alignment="CENTER"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="8.0" leading="8" alignment="CENTER"/>
<paraStyle name="P3" fontName="Times-Roman" fontSize="5.0" leading="8" alignment="CENTER"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="5.0" leading="8" alignment="CENTER"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<story>
[[ repeatIn(objects,'o') ]]
<blockTable colWidths="5.3cm" style="Tableau1">
<tr>
<td>
<para style="P1">[[ str(o.name) ]]</para>
<barCode code="code128" x="300" height="180" quiet="9" fontName="Times-Roman" fontSize="50" alignment="CENTER">[['ID'+str(o.id)]]</barCode>
</td>
</tr>
</blockTable>
</story>
</document>
@@ -130,6 +130,6 @@
from openerp import tools
from openerp.report import render_report
ids = [ref('mrp.mrp_workcenter_0'), ref('mrp.mrp_workcenter_1')]
data, format = render_report(cr, uid, ids, 'mrp.wc.barcode', {})
data, format = render_report(cr, uid, ids, 'mrp_operations.report_wcbarcode', {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'mrp_operations-workcenter_barcode_report.'+format), 'wb+').write(data)
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_wcbarcode">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<div class="page">
<div class="row">
<pre class="col-xs-4 col-xs-offset-4" style="background: #ffffff;">
<p class="text-center mb128"><strong t-field="o.name"/></p>
<p class="mt16"><img t-if="o.code" t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' %('Code128', o.code, 600, 160)" style="width:150px;"/></p>
</pre>
</div>
</div>
</t>
</t>
</template>
</data>
</openerp>