Sale category, from branch arom
bzr revid: rde-e1a6482f40f92a0e645ebd8237bcadace6b13797
This commit is contained in:
parent
687d8ee25f
commit
95c60d66ee
|
@ -0,0 +1 @@
|
||||||
|
import report
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"name" : "Sale Order Line With Categories",
|
||||||
|
"author" : "Tiny",
|
||||||
|
"version" : "1.0",
|
||||||
|
"category" : "Generic Modules/Sales & Purchases",
|
||||||
|
"depends" : ["sale"],
|
||||||
|
"demo_xml" : [],
|
||||||
|
"update_xml" : ["sale_category_report.xml"],
|
||||||
|
"active": True,
|
||||||
|
"installable": True
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
import sale_category_report
|
|
@ -0,0 +1,37 @@
|
||||||
|
import pooler
|
||||||
|
import time
|
||||||
|
from report import report_sxw
|
||||||
|
|
||||||
|
class sale_category_report(report_sxw.rml_parse):
|
||||||
|
# o must be an instance of sale_order. Returns a list of 2-tuple
|
||||||
|
# (category name, [list of sale_order_line of this category])
|
||||||
|
def order_lines_by_categ(self, o):
|
||||||
|
# result is a dictionnary where keys are category
|
||||||
|
# names and values are lists of sale_category_sale_order_line.
|
||||||
|
|
||||||
|
self.pool = pooler.get_pool(self.cr.dbname)
|
||||||
|
ids = self.pool.get('product.category').search(self.cr, self.uid, [('parent_id','=',False)])
|
||||||
|
cats = map(lambda x: (x, (x.sequence,)), self.pool.get('product.category').browse(self.cr, self.uid, ids))
|
||||||
|
pos = 0
|
||||||
|
result = {}
|
||||||
|
while pos<len(cats):
|
||||||
|
for c2 in cats[pos][0].child_id[::-1]:
|
||||||
|
cats.insert(pos+1, (c2, cats[pos][1]+(cats[pos][0].sequence,)))
|
||||||
|
for line in o.order_line:
|
||||||
|
if line.product_id.categ_id == cats[pos][0]:
|
||||||
|
result.setdefault( (cats[pos][1], cats[pos][0].complete_name), []).append(line)
|
||||||
|
pos += 1
|
||||||
|
return sorted(result.items())
|
||||||
|
|
||||||
|
def __init__(self, cr, uid, name, context):
|
||||||
|
super(sale_category_report, self).__init__(cr, uid, name, context)
|
||||||
|
self.localcontext.update( {
|
||||||
|
'time' : time,
|
||||||
|
'order_lines_by_categ' : self.order_lines_by_categ,
|
||||||
|
} )
|
||||||
|
|
||||||
|
report_sxw.report_sxw(
|
||||||
|
'report.sale_category.print',
|
||||||
|
'sale.order',
|
||||||
|
'addons/sale_category/report/sale_category_report.rml',
|
||||||
|
parser=sale_category_report)
|
|
@ -0,0 +1,280 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<document filename="test.pdf">
|
||||||
|
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" 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="Tableau1">
|
||||||
|
<blockAlignment value="LEFT"/>
|
||||||
|
<blockValign value="TOP"/>
|
||||||
|
</blockTableStyle>
|
||||||
|
<blockTableStyle id="Tableau2">
|
||||||
|
<blockAlignment value="LEFT"/>
|
||||||
|
<blockValign value="TOP"/>
|
||||||
|
<lineStyle kind="GRID" colorName="black"/>
|
||||||
|
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
|
||||||
|
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
|
||||||
|
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
|
||||||
|
<blockBackground colorName="#e6e6e6" start="3,0" stop="3,0"/>
|
||||||
|
<blockBackground colorName="#e6e6e6" start="4,0" stop="4,0"/>
|
||||||
|
<blockBackground colorName="#e6e6e6" start="5,0" stop="5,0"/>
|
||||||
|
<blockBackground colorName="#e6e6e6" start="6,0" stop="6,0"/>
|
||||||
|
</blockTableStyle>
|
||||||
|
<blockTableStyle id="Tableau3">
|
||||||
|
<blockAlignment value="LEFT"/>
|
||||||
|
<blockValign value="TOP"/>
|
||||||
|
</blockTableStyle>
|
||||||
|
<blockTableStyle id="Tableau8">
|
||||||
|
<blockAlignment value="LEFT"/>
|
||||||
|
<blockValign value="TOP"/>
|
||||||
|
</blockTableStyle>
|
||||||
|
<blockTableStyle id="Tableau9">
|
||||||
|
<blockAlignment value="LEFT"/>
|
||||||
|
<blockValign value="TOP"/>
|
||||||
|
</blockTableStyle>
|
||||||
|
<blockTableStyle id="Tableau4">
|
||||||
|
<blockAlignment value="LEFT"/>
|
||||||
|
<blockValign value="TOP"/>
|
||||||
|
</blockTableStyle>
|
||||||
|
<initialize>
|
||||||
|
<paraStyle name="all" alignment="justify"/>
|
||||||
|
</initialize>
|
||||||
|
<paraStyle name="P1" fontName="Times-Roman" fontSize="9.0" leading="11"/>
|
||||||
|
<paraStyle name="P2" fontName="Times-Bold" fontSize="9.0" leading="11"/>
|
||||||
|
<paraStyle name="P3" fontName="Times-Roman" fontSize="10.0" leading="13"/>
|
||||||
|
<paraStyle name="P4" fontName="Times-Roman" fontSize="10.0" leading="13"/>
|
||||||
|
<paraStyle name="P5" fontName="Times-Roman" fontSize="4.0" leading="5"/>
|
||||||
|
<paraStyle name="P6" fontName="Times-Bold" fontSize="9.0" leading="11"/>
|
||||||
|
<paraStyle name="P7" fontName="Times-Roman" fontSize="11.0" leading="14"/>
|
||||||
|
<paraStyle name="P8" fontName="Times-Roman" fontSize="11.0" leading="14"/>
|
||||||
|
<paraStyle name="P9" fontName="Times-Roman" fontSize="4.0" leading="5"/>
|
||||||
|
<paraStyle name="P10" fontName="Times-Roman" fontSize="8.0" leading="10"/>
|
||||||
|
<paraStyle name="P11" fontName="Times-Roman" fontSize="16.0" leading="20"/>
|
||||||
|
<paraStyle name="P12" fontName="Times-Roman" fontSize="11.0" leading="14"/>
|
||||||
|
<paraStyle name="P13" fontName="Times-Roman" fontSize="10.0" leading="13"/>
|
||||||
|
<paraStyle name="P14" fontName="Times-Bold" fontSize="8.0" leading="10"/>
|
||||||
|
<paraStyle name="P15" fontName="Times-Bold" fontSize="8.0" leading="10" alignment="CENTER"/>
|
||||||
|
<paraStyle name="P16" fontName="Times-BoldItalic" fontSize="6.0" leading="8" alignment="LEFT"/>
|
||||||
|
<paraStyle name="P17" fontName="Times-Bold" fontSize="12.0" leading="15" alignment="LEFT"/>
|
||||||
|
<paraStyle name="P18" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT"/>
|
||||||
|
<paraStyle name="P19" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="CENTER"/>
|
||||||
|
<paraStyle name="P20" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT"/>
|
||||||
|
<paraStyle name="P21" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="RIGHT"/>
|
||||||
|
<paraStyle name="P22" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="RIGHT"/>
|
||||||
|
<paraStyle name="P23" fontName="Times-BoldItalic" fontSize="9.0" leading="11" alignment="LEFT"/>
|
||||||
|
<paraStyle name="P24" fontName="Times-Italic" fontSize="9.0" leading="11" alignment="LEFT"/>
|
||||||
|
<paraStyle name="P25" fontName="Times-Roman" fontSize="7.0" leading="9"/>
|
||||||
|
<paraStyle name="P26" fontName="Times-Bold" fontSize="9.0" leading="11" alignment="RIGHT"/>
|
||||||
|
<paraStyle name="P27" fontName="Times-Roman" fontSize="7.0" leading="9"/>
|
||||||
|
<paraStyle name="P28" fontName="Times-Bold" fontSize="9.0" leading="11" alignment="RIGHT"/>
|
||||||
|
<paraStyle name="P29" fontName="Times-Bold" fontSize="9.0" leading="11"/>
|
||||||
|
<paraStyle name="P30" fontName="Times-Roman" alignment="LEFT"/>
|
||||||
|
<paraStyle name="P31" fontName="Times-Roman" alignment="LEFT"/>
|
||||||
|
<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="Table Heading" fontName="Times-Roman" alignment="CENTER"/>
|
||||||
|
<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>
|
||||||
|
<para style="P1">[[ repeatIn(objects,'o') ]] <font face="Times-Roman">[[ setLang(o.partner_id.lang) ]]</font></para>
|
||||||
|
<blockTable colWidths="257.0,50.0,220.0" style="Tableau1">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<para style="P2">Shipping address :</para>
|
||||||
|
<para style="P3">[[ o.partner_id.title or '' ]] [[ o.partner_id.name ]]</para>
|
||||||
|
<para style="P3">[[ o.partner_shipping_id.title or '' ]] [[ o.partner_shipping_id.name ]]</para>
|
||||||
|
<para style="P3">[[ o.partner_shipping_id.street ]]</para>
|
||||||
|
<para style="P3">[[ o.partner_shipping_id.street2 or '' ]]</para>
|
||||||
|
<para style="P4"><font face="Times-Roman">[[ o.partner_shipping_id.zip or '' ]]</font> [[ o.partner_shipping_id.city or '' ]]</para>
|
||||||
|
<para style="P4">[[ o.partner_shipping_id.state_id and o.partner_shipping_id.state_id.name or '' ]]</para>
|
||||||
|
<para style="P4">[[ o.partner_shipping_id.country_id and o.partner_shipping_id.country_id.name or '' ]]</para>
|
||||||
|
<para style="P5">
|
||||||
|
<font color="white"> </font>
|
||||||
|
</para>
|
||||||
|
<para style="P6">Invoice address :</para>
|
||||||
|
<para style="P4">[[ o.partner_invoice_id.street ]][[ o.partner_invoice_id.street2 and ', %s' % o.partner_invoice_id.street2 or '' ]]</para>
|
||||||
|
<para style="P4">[[ o.partner_invoice_id.zip or '' ]] [[ o.partner_invoice_id.city or '' ]] [[ ', %s' % (o.partner_invoice_id.country_id and o.partner_invoice_id.country_id.name or '') ]]</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P7">
|
||||||
|
<font color="white"> </font>
|
||||||
|
</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P8">[[ o.partner_id.title or '' ]] [[ o.partner_id.name ]]</para>
|
||||||
|
<para style="P8">[[ o.partner_order_id.title or '' ]] [[ o.partner_order_id.name ]]</para>
|
||||||
|
<para style="P8">[[ o.partner_order_id.street ]]</para>
|
||||||
|
<para style="P8">[[ o.partner_order_id.street2 or '' ]]</para>
|
||||||
|
<para style="P8">[[ o.partner_order_id.zip or '' ]] [[ o.partner_order_id.city or '' ]]</para>
|
||||||
|
<para style="P8">[[ o.partner_order_id.state_id and o.partner_order_id.state_id.name or '' ]]</para>
|
||||||
|
<para style="P8">[[ o.partner_order_id.country_id and o.partner_order_id.country_id.name or '' ]]</para>
|
||||||
|
<para style="P9">
|
||||||
|
<font color="white"> </font>
|
||||||
|
</para>
|
||||||
|
<para style="P3">Tél. : [[ o.partner_order_id.phone or '' ]]</para>
|
||||||
|
<para style="P3">Fax : [[ o.partner_order_id.fax or '' ]]</para>
|
||||||
|
<para style="P3">TVA : [[ o.partner_id.vat or '' ]]</para>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</blockTable>
|
||||||
|
<para style="P10">
|
||||||
|
<font color="white"> </font>
|
||||||
|
</para>
|
||||||
|
<para style="P11">[[ o.state=='draft' and 'Quotation ' or 'Order ' ]] N° : [[ o.name ]]</para>
|
||||||
|
<para style="P3">
|
||||||
|
<font color="white"> </font>
|
||||||
|
</para>
|
||||||
|
<para style="P12">Your order reference : [[ o.client_order_ref or '' ]]</para>
|
||||||
|
<para style="P12">Date ordered : [[ time.strftime('%d/%m/%Y', time.strptime(o.date_order, '%Y-%m-%d')) ]]</para>
|
||||||
|
<para style="P12">Our salesman : [[ o.user_id.name ]]</para>
|
||||||
|
<para style="P13">[[o.topnote or '']]</para>
|
||||||
|
<blockTable colWidths="218.0,66.0,50.0,57.0,28.0,54.0,55.0" repeatRows="1" style="Tableau2">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<para style="P14">Product Description</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P15">Applicable Taxes</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P14">Date Promised</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P14">Qty</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P14">Disc.</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P14">Unit Price</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P14">Net Price</para>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</blockTable>
|
||||||
|
<section>
|
||||||
|
<para style="P16">[[repeatIn(order_lines_by_categ(o), 'cat')]]</para>
|
||||||
|
<para style="P17">[[cat[0][1] ]]</para>
|
||||||
|
<section>
|
||||||
|
<para style="P16">[[ repeatIn(cat[1],'line') ]]</para>
|
||||||
|
<blockTable colWidths="219.0,66.0,49.0,57.0,28.0,53.0,55.0" style="Tableau3">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<para style="P18">[[ line.name ]]</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P19">[[ ', '.join(map(lambda x: x.name, line.tax_id))]]</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P19">[[ time.strftime('%d/%m/%Y', time.strptime( line.date_planned, '%Y-%m-%d')) ]]</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P20">[[ line.product_uom_qty ]] [[ line.product_uom.name ]]</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P18">[[ (line.discount and str(line.discount)+'%')or '' ]]</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P21">[[ '%.2f' % line.price_unit ]]</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P22">[[ '%.2f' % line.price_subtotal ]]</para>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</blockTable>
|
||||||
|
<para style="P16">
|
||||||
|
<font color="white"> </font>
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
<blockTable colWidths="52.0,366.0,110.0" style="Tableau8">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<para style="P23">[[ repeatIn((line.notes and [line.notes]) or [], 'l') ]]</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P24">[[ l ]] [[ setTag('para','xpre') ]]</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P23">
|
||||||
|
<font color="white"> </font>
|
||||||
|
</para>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</blockTable>
|
||||||
|
</section>
|
||||||
|
<blockTable colWidths="348.0,69.0,110.0" style="Tableau9">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<para style="P25">
|
||||||
|
<font color="white"> </font>
|
||||||
|
</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P26">Net Total :</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P26">[[ '%.2f' % o.amount_untaxed ]] [[ o.pricelist_id.currency_id.name ]]</para>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<para style="P25">
|
||||||
|
<font color="white"> </font>
|
||||||
|
</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P26">Taxes :</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P26">[[ '%.2f' % o.amount_tax ]] [[ o.pricelist_id.currency_id.name ]]</para>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<para style="P27">
|
||||||
|
<font color="white"> </font>
|
||||||
|
</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P28">TOTAL :</para>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<para style="P28">[[ '%.2f' % o.amount_total ]] [[ o.pricelist_id.currency_id.name ]]</para>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</blockTable>
|
||||||
|
<para style="P29">
|
||||||
|
<font color="white"> </font>
|
||||||
|
</para>
|
||||||
|
<para style="P29">
|
||||||
|
<font color="white"> </font>
|
||||||
|
</para>
|
||||||
|
<blockTable colWidths="527.0" style="Tableau4">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<para style="P30">[[ o.note or '' ]] [[ setTag('para','xpre') ]]</para>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<para style="P30">[[ 'xpre' and o.partner_id.property_payment_term and o.partner_id.property_payment_term[1] ]] [[ setTag('para','xpre') ]]</para>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</blockTable>
|
||||||
|
<para style="P31">
|
||||||
|
<font color="white"> </font>
|
||||||
|
</para>
|
||||||
|
</story>
|
||||||
|
</document>
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<terp>
|
||||||
|
<data>
|
||||||
|
<report id="sale_category_print"
|
||||||
|
string="Sales Orders By Categories"
|
||||||
|
model="sale.order"
|
||||||
|
name="sale_category.print"
|
||||||
|
rml="sale_category/report/sale_category_report.rml"
|
||||||
|
auto="False"/>
|
||||||
|
</data>
|
||||||
|
</terp>
|
Loading…
Reference in New Issue