[MERGE]:merged from lp:~openerp-commiter/+junk/report-common

bzr revid: apa@tinyerp.com-20101012044634-xhcmw3agfoie1nrc
This commit is contained in:
apa-tiny
2010-10-12 10:16:34 +05:30
9 changed files with 58 additions and 45 deletions
@@ -211,7 +211,7 @@
<para style="terp_tblheader_Details_Right">Disc.(%)</para>
</td>
<td>
<para style="terp_tblheader_Details_Centre">Price</para>
<para style="terp_tblheader_Details_Right">Price</para>
</td>
</tr>
</blockTable>
@@ -229,7 +229,7 @@
<para style="terp_default_Right_9">[[ formatLang(l.quantity)]] [[ (l.uos_id and l.uos_id.name) or '' ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ formatLang(l.price_unit) ]][[ o.currency_id.symbol ]]</para>
<para style="terp_default_Right_9">[[ formatLang(l.price_unit) ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ formatLang(l.discount, digits=get_digits(dp='Account')) ]] </para>
+2 -2
View File
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="HR Expenses" author="OpenERP S.A. (sales@openerp.com)" allowSplitting="20">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="16.0" y1="57.0" width="522" height="728"/>
</pageTemplate>
@@ -259,7 +259,7 @@
<para style="terp_default_9">
<font color="white"> </font>
</para>
<para style="terp_default_9">[[ o.note or '' ]] [[ setTag('para','xpre') ]]</para>
<para style="terp_default_9">[[ o.note or removeParentNode('para')]] </para>
<para style="terp_default_9">
<font color="white"> </font>
</para>
+2 -2
View File
@@ -275,7 +275,7 @@
<para style="terp_default_9">[[ p['name'] or removeParentNode('para') ]]</para>
</td>
<td>
<para style="terp_default_Right_9_Bold">[[ formatLang(p['amount']) or removeParentNode('font') ]] [[ company.currency_id.symbol ]]</para>
<para style="terp_default_Right_9_Bold">[[ formatLang(p['amount']) or removeParentNode('tr') ]] [[ company.currency_id.symbol ]]</para>
</td>
</tr>
</blockTable>
@@ -383,4 +383,4 @@
<font color="white"> </font>
</para>
</story>
</document>
</document>
@@ -38,7 +38,8 @@ class pos_details_summary(report_sxw.rml_parse):
'getsuminvoice': self._sum_invoice,
'gettaxamount': self._get_tax_amount,
'getsalestotal': self._get_sales_total,
'getperiod': self._get_period,
'getstartperiod': self._get_start_period,
'getendperiod': self._get_end_period,
'getcompany':self.get_company
})
@@ -68,27 +69,26 @@ class pos_details_summary(report_sxw.rml_parse):
objects,
0.0 )
def _get_payments(self, objects, ignore_gift=False):
gift_journal_id = None
if ignore_gift:
config_journal_ids = self.pool.get("pos.config.journal").search(self.cr, self.uid, [('code', '=', 'GIFT')])
if len(config_journal_ids):
config_journal = self.pool.get("pos.config.journal").browse(self.cr, self.uid, config_journal_ids, {})[0]
gift_journal_id = config_journal.journal_id.id
def _get_payments(self, objects):
# gift_journal_id = None
# if ignore_gift:
# config_journal_ids = self.pool.get("pos.config.journal").search(self.cr, self.uid, [('code', '=', 'GIFT')])
# if len(config_journal_ids):
# config_journal = self.pool.get("pos.config.journal").browse(self.cr, self.uid, config_journal_ids, {})[0]
# gift_journal_id = config_journal.journal_id.id
result = {}
for obj in objects:
for payment in obj.statement_ids:
if gift_journal_id and gift_journal_id == payment.statement_id.journal_id.id:
continue
result[payment.statement_id.journal_id.name] = result.get(payment.statement_id.journal_id.name, 0.0) + payment.amount
for statement in obj.statement_ids:
if statement.journal_id:
result[statement.journal_id] = result.get(statement.journal_id, 0.0) + statement.amount
return result
def _paid_total(self, objects):
return sum(self._get_payments(objects, True).values(), 0.0)
return sum(self._get_payments(objects).values(), 0.0)
def _total_of_the_day(self, objects):
total_paid = sum(self._get_payments(objects, True).values(), 0.0)
total_paid = self._paid_total(objects)
total_invoiced = self._sum_invoice(objects)
return total_paid - total_invoiced
@@ -119,15 +119,23 @@ class pos_details_summary(report_sxw.rml_parse):
def _get_sales_total(self, objects):
return reduce(lambda x, o: x + len(o.lines), objects, 0)
def _get_period(self, objects):
def _get_start_period(self, objects):
date_orders = [obj.date_order for obj in objects]
min_date = min(date_orders)
max_date = max(date_orders)
if min_date == max_date:
return '%s' % min_date
else:
return '%s - %s' % (min_date, max_date)
return '%s' % min_date
def _get_end_period(self, objects):
date_orders = [obj.date_order for obj in objects]
min_date = min(date_orders)
max_date = max(date_orders)
if min_date == max_date:
return '%s' % max_date
else:
return '%s' % max_date
report_sxw.report_sxw('report.pos.details_summary',
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Detail of sales" author="OpenERP S.A. (sales@openerp.com)" allowSplitting="20">
<template pageSize="(595.0,842.0)" title="Details of Sales" author="OpenERP S.A. (sales@openerp.com)" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="27.0" y1="57.0" width="512" height="728"/>
</pageTemplate>
@@ -20,9 +20,12 @@
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="2,0" stop="2,-1"/>
<lineStyle kind="LINEAFTER" colorName="#e6e6e6" start="2,0" stop="2,-1"/>
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEAFTER" colorName="#e6e6e6" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="3,0" stop="3,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
@@ -34,9 +37,12 @@
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="2,0" stop="2,-1"/>
<lineStyle kind="LINEAFTER" colorName="#e6e6e6" start="2,0" stop="2,-1"/>
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEAFTER" colorName="#e6e6e6" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="3,0" stop="3,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
@@ -157,7 +163,7 @@
<para style="P4">
<font color="white"> </font>
</para>
<blockTable colWidths="170.0,170.0,170.0" style="Table1">
<blockTable colWidths="170.0,170.0,85.0,85.0" style="Table1">
<tr>
<td>
<para style="terp_tblheader_General_Centre">Company</para>
@@ -166,11 +172,14 @@
<para style="terp_tblheader_General_Centre">Print Date</para>
</td>
<td>
<para style="terp_tblheader_General_Centre">Period</para>
<para style="terp_tblheader_General_Centre">Start Period</para>
</td>
<td>
<para style="terp_tblheader_General_Centre">End Period</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="170.0,170.0,170.0" style="Table2">
<blockTable colWidths="170.0,170.0,85.0,85.0" style="Table2">
<tr>
<td>
<para style="terp_default_Centre_8">[[ '%s' % getcompany(objects)]]</para>
@@ -179,7 +188,10 @@
<para style="terp_default_Centre_8">[[ formatLang(time.strftime('%Y-%m-%d'),date=True) ]]</para>
</td>
<td>
<para style="terp_default_Centre_8">[[ '%s' % getperiod(objects) ]]</para>
<para style="terp_default_Centre_8">[[ '%s' % getstartperiod(objects) ]]</para>
</td>
<td>
<para style="terp_default_Centre_8">[[ '%s' % getendperiod(objects) ]]</para>
</td>
</tr>
</blockTable>
@@ -206,17 +218,14 @@
<para style="P6">[[ p[0] ]]</para>
</td>
<td>
<para style="terp_default_Right_9_Bold">[[ p[1] ]]</para>
<para style="terp_default_Right_9_Bold">[[ p[1] ]] [[company.currency_id.symbol]]</para>
</td>
</tr>
</blockTable>
<para style="terp_default_1">
<para style="terp_default_9">
<font color="white"> </font>
</para>
</section>
<para style="terp_default_8">
<font color="white"> </font>
</para>
<blockTable colWidths="256.0,256.0" style="Table3">
<tr>
<td>
@@ -237,17 +246,14 @@
<para style="P5">[[ t[0] ]]</para>
</td>
<td>
<para style="terp_default_Right_9_Bold">[[ '%.2f' % (t[1],) ]]</para>
<para style="terp_default_Right_9_Bold">[[ '%.2f' % (t[1],) ]] [[company.currency_id.symbol]]</para>
</td>
</tr>
</blockTable>
<para style="terp_default_1">
<para style="terp_default_9">
<font color="white"> </font>
</para>
</section>
<para style="terp_default_8">
<font color="white"> </font>
</para>
<blockTable colWidths="256.0,256.0" style="Table8">
<tr>
<td>
@@ -184,7 +184,7 @@
<para style="terp_default_Right_9">[[ formatLang(line_ids['discount']) ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ formatLang(line_ids['price_unit']) ]] [[ company.currency_id.symbol ]]</para>
<para style="terp_default_Right_9">[[ formatLang(line_ids['price_unit']) ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ formatLang(line_ids['total']) ]] [[ company.currency_id.symbol ]]</para>
@@ -161,7 +161,7 @@
<para style="terp_default_Right_9">[[ formatLang(line_ids['discount']) ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ formatLang(line_ids['price_unit']) ]] [[ company.currency_id.symbol ]]</para>
<para style="terp_default_Right_9">[[ formatLang(line_ids['price_unit']) ]] </para>
</td>
<td>
<para style="terp_default_Right_9">[[ formatLang(line_ids['total']) ]] [[ company.currency_id.symbol ]]</para>
@@ -25,7 +25,7 @@ from report import report_sxw
class pos_user_product(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(pos_user_product, self).__init__(cr, uid, name, context=context)
super(pos_user_product, self).__init__(cr, uid, name, context)
self.total = 0.0
self.localcontext.update({
'time': time,
@@ -43,7 +43,7 @@ class pos_user_product(report_sxw.rml_parse):
for r in data:
a_l.append(r['id'])
if len(a_l):
sql2="""SELECT sum(qty) as qty,l.price_unit*sum(l.qty) as amt,t.name as name from product_product p, product_template t, pos_order_line l where order_id IN %s and p.product_tmpl_id=t.id and l.product_id=p.id group by t.name, l.price_unit""",(tuple(a_l),)
sql2="""SELECT sum(qty) as qty,l.price_unit*sum(l.qty) as amt,t.name as name from product_product p, product_template t, pos_order_line l where order_id = %d and p.product_tmpl_id=t.id and l.product_id=p.id group by t.name, l.price_unit"""%(o.id)
self.cr.execute(sql2)
data = self.cr.dictfetchall()
for d in data:
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="User's Product" author="OpenERP S.A. (sales@openerp.com)" allowSplitting="20">
<template pageSize="(595.0,842.0)" title="Users Product'" author="OpenERP S.A. (sales@openerp.com)" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
@@ -82,7 +82,6 @@
</initialize>
<paraStyle name="P1" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT"/>
<paraStyle name="P2" fontName="Helvetica-Bold" fontSize="14.0" leading="17" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P3" fontName="Helvetica" fontSize="6.0" leading="8" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<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"/>