[IMP] Lunch order report converted to QWeb

bzr revid: openerp-sle@openerp-sle.home-20140217140523-591vtpvc5yd6nuuv
This commit is contained in:
openerp-sle 2014-02-17 15:05:23 +01:00
parent 1dfb35be10
commit 67fc7252c5
5 changed files with 100 additions and 200 deletions

View File

@ -42,7 +42,7 @@ If you want to save your employees' time and avoid them to always have coins in
""",
'data': ['security/lunch_security.xml','lunch_view.xml','wizard/lunch_order_view.xml','wizard/lunch_validation_view.xml','wizard/lunch_cancel_view.xml','lunch_report.xml',
'report/report_lunch_order_view.xml',
'security/ir.model.access.csv',],
'security/ir.model.access.csv','views/report_lunchorder.xml'],
'css':['static/src/css/lunch.css'],
'images': ['images/new_order.jpeg','images/lunch_account.jpeg','images/order_by_supplier_analysis.jpeg','images/alert.jpeg'],
'demo': ['lunch_demo.xml',],

View File

@ -2,12 +2,12 @@
<openerp>
<data>
<report
id="report_lunch_order"
id="action_report_lunch_order"
string="Lunch Order"
model="lunch.order.line"
name="lunch.order.line"
rml="lunch/report/order.rml"
auto="False"
/>
report_type="qweb-pdf"
name="lunch.report_lunchorder"
file="lunch.report_lunchorder"
/>
</data>
</openerp>

View File

@ -20,11 +20,11 @@
##############################################################################
import time
from openerp.report import report_sxw
from openerp.osv import osv
from openerp.addons.web import http
from openerp.addons.web.http import request
class order(report_sxw.rml_parse):
class order(http.Controller):
def get_lines(self, user,objects):
lines=[]
@ -60,19 +60,24 @@ class order(report_sxw.rml_parse):
notes.append(obj.note)
return notes
def __init__(self, cr, uid, name, context):
super(order, self).__init__(cr, uid, name, context)
@http.route(['/report/lunch.report_lunchorder/<docids>'], type='http', auth='user', website=True, multilang=True)
def report_lunch(self, docids):
self.cr, self.uid, self.context = request.cr, request.uid, request.context
ids = [int(i) for i in docids.split(',')]
report_obj = request.registry['lunch.order.line']
docs = report_obj.browse(self.cr, self.uid, ids, context=self.context)
self.net_total=0.0
self.localcontext.update({
docargs = {
'docs': docs,
'time': time,
'get_lines': self.get_lines,
'get_users': self.get_users,
'get_total': self.get_total,
'get_nettotal': self.get_nettotal,
'get_note': self.get_note,
})
}
return request.registry['report'].render(self.cr, self.uid, [], 'lunch.report_lunchorder', docargs)
report_sxw.report_sxw('report.lunch.order.line', 'lunch.order.line',
'addons/lunch/report/order.rml',parser=order, header='external')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,184 +0,0 @@
<?xml version="1.0"?>
<document filename="Lunch Order.pdf">
<template title="Lunch Order" author="OpenERP S.A.(sales@openerp.com)" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="34.0" y1="42.0" width="527" height="758"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table5">
<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="Table6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBELOW" colorName="#b3b3b3" start="0,-1" stop="0,-1"/>
</blockTableStyle>
<blockTableStyle id="Table7">
<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>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="Standard" fontName="Helvetica"/>
<paraStyle name="Text body" fontName="Helvetica" 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="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Header" fontName="Helvetica"/>
<paraStyle name="Footer" fontName="Helvetica"/>
<paraStyle name="Table Contents" fontName="Helvetica"/>
<paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER"/>
<paraStyle name="Caption" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Footnote" rightIndent="0.0" leftIndent="14.0" fontName="Helvetica" fontSize="10.0" leading="13"/>
<paraStyle name="Index" fontName="Helvetica"/>
<paraStyle name="Heading 1" fontName="Helvetica-Bold" fontSize="115%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
<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_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_tbl_detail_header" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_tbl_detail_header_right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_tbl_detail_header_center" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_9_right" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_9_right_bold" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_header_center" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_9_center" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_2" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_9_left9" rightIndent="0.0" leftIndent="9.0" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<images/>
</stylesheet>
<story>
<pto>
<pto_header>
<blockTable colWidths="149.0,114.0,201.0,63.0" style="Table5">
<tr>
<td>
<para style="terp_tbl_detail_header">Name/Date</para>
</td>
<td>
<para style="terp_tbl_detail_header">Order</para>
</td>
<td>
<para style="terp_tbl_detail_header">Description</para>
</td>
<td>
<para style="terp_tbl_detail_header_right">Unit Price</para>
</td>
</tr>
</blockTable>
</pto_header>
<para style="terp_default_8">
<font color="white"> </font>
</para>
<blockTable colWidths="293.0,235.0" style="Table1">
<tr>
<td>
<para style="terp_default_8">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_8">[[ user.name ]] </para>
<para style="terp_default_8">[[ user.login ]]</para>
<para style="terp_default_8">[[ user.email ]]</para>
</td>
</tr>
</blockTable>
<para style="terp_header">Lunch Order</para>
<blockTable colWidths="149.0,114.0,201.0,63.0" style="Table5">
<tr>
<td>
<para style="terp_tbl_detail_header">Name/Date</para>
</td>
<td>
<para style="terp_tbl_detail_header">Order</para>
</td>
<td>
<para style="terp_tbl_detail_header">Description</para>
</td>
<td>
<para style="terp_tbl_detail_header_right">Unit Price</para>
</td>
</tr>
</blockTable>
<section>
<para style="terp_default_2">[[repeatIn(get_users(objects),'o')]]</para>
<blockTable colWidths="263.0,201.0,63.0" style="Table6">
<tr>
<td>
<para style="terp_tbl_detail_header">[[ o.name ]]</para>
</td>
<td>
<para style="terp_default_8">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_9_right_bold"><u>[[ formatLang(get_total(o,objects)) ]] [[ (o.company_id and o.company_id.currency_id and o.company_id.currency_id.symbol) or '' ]]</u></para>
</td>
</tr>
</blockTable>
<section>
<para style="terp_default_2">[[ repeatIn(get_lines(o,objects),'lines') ]]</para>
<blockTable colWidths="151.0,113.0,216.0,49.0" style="Table7">
<tr>
<td>
<para style="terp_default_9_left9">[[ formatLang(lines.date,date='True') ]]</para>
</td>
<td>
<para style="terp_default_9">[[ (lines.product_id and lines.product_id.name) or '' ]]</para>
</td>
<td>
<para style="terp_default_9">[[ lines.note]]</para>
</td>
<td>
<para style="terp_default_9_right">[[ lines.price ]] [[ (o.company_id and o.company_id.currency_id and o.company_id.currency_id.symbol) or '' ]]</para>
</td>
</tr>
</blockTable>
</section>
</section>
<blockTable colWidths="409.0,50.0,70.0" style="Table2">
<tr>
<td>
<para style="terp_default_8">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_tbl_detail_header">Total :</para>
</td>
<td>
<para style="terp_default_9_right_bold">[[ formatLang(get_nettotal()) ]] [[ (o.company_id and o.company_id.currency_id and o.company_id.currency_id.symbol) or '' ]]</para>
</td>
</tr>
</blockTable>
<para style="terp_default_2">
<font color="white"> </font>
</para>
</pto>
</story>
</document>

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_lunchorder">
<t t-call="report.html_skeleton">
<t t-call="report.external_layout">
<div class="page">
<div class="oe_structure"/>
<div class="row">
<div class="col-xs-4 col-xs-offset-7">
<div t-field="user.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}' />
</div>
</div>
<h2>Lunch Order</h2>
<table class="table table-condensed">
<thead>
<tr>
<th>Name/Date</th>
<th>Order</th>
<th>Description</th>
<th class="text-right">Unit Price</th>
</tr>
</thead>
<tbody>
<t t-foreach="get_users(docs)" t-as="o">
<tr>
<td colspan="2">
<strong t-field="o.name"/>
</td>
<td class="text-right" colspan="2">
<strong>
<span t-esc="get_total(o, docs)"/>
<span t-field="o.company_id.currency_id.symbol"/>
</strong>
</td>
</tr>
<tr t-foreach="get_lines(o, docs)" t-as="lines">
<td>
<span t-field="lines.date"></span>
</td>
<td>
<span t-field="lines.product_id.name"/>
</td>
<td>
<span t-field="lines.note"/>
</td>
<td class="text-right">
<span t-field="lines.price"
t-field-options='{"widget": "monetary", "display_currency": "o.company_id.currency_id"}'/>
</td>
</tr>
</t>
</tbody>
</table>
<div class="row">
<div class="col-xs-4 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<td><strong>Total</strong></td>
<td class="text-right">
<span t-esc="formatLang(get_nettotal(), currency_obj=res_company.currency_id)"/>
</td>
</tr>
</table>
</div>
</div>
<div class="oe_structure"/>
</div>
</t>
</t>
</template>
</data>
</openerp>