[REM] product: removed dead price list report.
bzr revid: vmt@openerp.com-20130220144129-nxwkh9vi64oafca9
This commit is contained in:
parent
7daccf5074
commit
73bf45f9a4
|
@ -1,117 +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 datetime
|
||||
from openerp.report.interface import report_rml
|
||||
from openerp.report.interface import toxml
|
||||
from openerp import pooler
|
||||
from openerp.osv import osv
|
||||
import datetime
|
||||
|
||||
class report_custom(report_rml):
|
||||
|
||||
def create_xml(self, cr, uid, ids, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
|
||||
price_list_id = data['form']['price_list']
|
||||
|
||||
product_categ_id =pool.get('product.category').search(cr, uid, [])
|
||||
currency = pool.get('product.pricelist').read(cr, uid, [price_list_id], ['currency_id','name'])[0]
|
||||
|
||||
|
||||
qty =[]
|
||||
|
||||
for i in range(1,6):
|
||||
q = 'qty%d'%i
|
||||
if data['form'][q]:
|
||||
qty.append(data['form'][q])
|
||||
|
||||
if not qty:
|
||||
qty.append(1)
|
||||
|
||||
product_xml = []
|
||||
cols = ''
|
||||
cols = cols+'6cm'
|
||||
title ='<title name=" Description " number="0" />'
|
||||
i=1
|
||||
for q in qty:
|
||||
cols = cols+',2.5cm'
|
||||
if q==1:
|
||||
title+='<title name="%d unit" number="%d"/>'%(q,i)
|
||||
else:
|
||||
title+='<title name="%d units" number="%d"/>'%(q,i)
|
||||
i+=1
|
||||
date = datetime.date.today()
|
||||
str_date=date.strftime("%d/%m/%Y")
|
||||
product_xml.append('<cols>'+cols+'</cols>')
|
||||
product_xml.append('<pricelist> %s </pricelist>'%currency['name'])
|
||||
product_xml.append('<currency> %s </currency>'%currency['currency_id'][1])
|
||||
product_xml.append('<date> %s </date>'%str_date)
|
||||
product_xml.append("<product>")
|
||||
|
||||
for p_categ_id in product_categ_id:
|
||||
product_ids = pool.get('product.product').search(cr, uid, [('id','in',ids),('categ_id','=',p_categ_id)])
|
||||
if product_ids:
|
||||
categ_name = pool.get('product.category').read(cr, uid, [p_categ_id], ['name'])
|
||||
products = pool.get('product.product').read(cr, uid, product_ids, ['id','name','code'])
|
||||
pro = []
|
||||
i=0
|
||||
pro.append('<pro name="%s" categ="true">' % (categ_name[0]['name']))
|
||||
temp = []
|
||||
for q in qty:
|
||||
temp.append('<price name=" " />')
|
||||
pro.extend(temp)
|
||||
pro.append('</pro>')
|
||||
for x in products:
|
||||
#Replacement of special characters with their code html for allowing reporting - Edited by Hasa
|
||||
x['name'] = x['name'].replace("&","&")
|
||||
x['name'] = x['name'].replace("\"",""")
|
||||
if x['code']:
|
||||
pro.append('<pro name="[%s] %s" >' % (x['code'], x['name']))
|
||||
else:
|
||||
pro.append('<pro name="%s" >' % (x['name']))
|
||||
temp = []
|
||||
for q in qty:
|
||||
price_dict = pool.get('product.pricelist').price_get(cr, uid, [price_list_id], x['id'], q, context=context)
|
||||
if price_dict[price_list_id]:
|
||||
price = price_dict[price_list_id]
|
||||
else:
|
||||
res = pool.get('product.product').read(cr, uid, [x['id']])
|
||||
price = res[0]['list_price']
|
||||
|
||||
temp.append('<price name="%.2f" />'%(price))
|
||||
i+=1
|
||||
pro.extend(temp)
|
||||
pro.append('</pro>')
|
||||
product_xml.extend(pro)
|
||||
|
||||
product_xml.append('</product>')
|
||||
|
||||
xml = '''<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<report>
|
||||
%s
|
||||
</report>
|
||||
''' % (title+'\n'.join(product_xml))
|
||||
return self.post_process_xml_data(cr, uid, xml, context)
|
||||
|
||||
report_custom('report.pricelist.pricelist', 'product.product','','addons/product_pricelist_print/report/product_price.xsl')
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:fo="http://www.w3.org/1999/XSL/Format">
|
||||
<xsl:import href="../../base/report/corporate_defaults.xsl" />
|
||||
<xsl:template match="/">
|
||||
<xsl:call-template name="rml" />
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="rml" match="/">
|
||||
<document filename="example.pdf">
|
||||
<template>
|
||||
<pageTemplate id="first">
|
||||
<frame id="first" x1="1cm" y1="2.5cm" width="19.0cm" height="23.0cm"/>
|
||||
<pageGraphics>
|
||||
<xsl:apply-imports />
|
||||
</pageGraphics>
|
||||
</pageTemplate>
|
||||
</template>
|
||||
<stylesheet>
|
||||
<paraStyle name="normal" fontName="Times-Roman" fontSize="12" />
|
||||
<paraStyle name="title" fontName="Times-Bold" fontSize="15" alignment="center" />
|
||||
<paraStyle name="table_title" fontName="Times-Bold" fontSize="12" alignment="center" />
|
||||
<paraStyle name="product1" fontName="Times-Roman" fontSize="8" />
|
||||
<paraStyle name="categ" fontName="Times-Bold" fontSize="10" textColor="blue"/>
|
||||
<paraStyle name="price" fontName="Times-Roman" fontSize="8" alignment="right" />
|
||||
|
||||
<blockTableStyle id="main_title">
|
||||
<blockAlignment value="CENTER" />
|
||||
<lineStyle kind="GRID" colorName="black"/>
|
||||
<blockBackground colorName="#e6e6e6" />
|
||||
<blockValign value="TOP"/>
|
||||
</blockTableStyle>
|
||||
|
||||
<blockTableStyle id="product">
|
||||
<blockAlignment value="LEFT" />
|
||||
<xsl:for-each select="/report/title">
|
||||
<xsl:variable name="col" select="attribute::number" />
|
||||
<blockBackground>
|
||||
<xsl:attribute name="colorName">#e6e6e6</xsl:attribute>
|
||||
<xsl:attribute name="start">
|
||||
<xsl:value-of select="$col" />
|
||||
<xsl:text>,0</xsl:text>
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="stop">
|
||||
<xsl:value-of select="$col" />
|
||||
<xsl:text>,0</xsl:text>
|
||||
</xsl:attribute>
|
||||
</blockBackground>
|
||||
</xsl:for-each>
|
||||
<lineStyle kind="LINEABOVE" colorName="black" start="0,0" stop="-1,-1" />
|
||||
<lineStyle kind="LINEBEFORE" colorName="black" start="0,0" stop="-1,-1"/>
|
||||
<lineStyle kind="LINEAFTER" colorName="black" start="-1,0" stop="-1,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="black" start="0,-1" stop="-1,-1"/>
|
||||
<blockValign value="TOP"/>
|
||||
</blockTableStyle>
|
||||
</stylesheet >
|
||||
<story>
|
||||
<xsl:call-template name="story"/>
|
||||
</story>
|
||||
</document>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="story">
|
||||
<spacer length="1cm" />
|
||||
<blockTable rowHeights="1cm">
|
||||
<xsl:attribute name="style">main_title</xsl:attribute>
|
||||
<tr> <td> <para style="title" t="1">Products Price List</para> </td> </tr>
|
||||
</blockTable>
|
||||
<spacer length="1cm" />
|
||||
<para style="normal" t="1">Price List Name :<xsl:value-of select="report/pricelist" /></para>
|
||||
<para style="normal" t="1">Currency : <xsl:value-of select="report/currency" /></para>
|
||||
<para style="normal" t="1">Printing Date : <xsl:value-of select="report/date" /></para>
|
||||
<spacer length="0.7cm" />
|
||||
<blockTable>
|
||||
<xsl:attribute name="style">product</xsl:attribute>
|
||||
<xsl:attribute name="colWidths"><xsl:value-of select="report/cols" /></xsl:attribute>
|
||||
<tr>
|
||||
<xsl:for-each select="report/title" >
|
||||
<td><para style="table_title"> <xsl:value-of select="attribute::name" /> </para></td>
|
||||
</xsl:for-each>
|
||||
</tr>
|
||||
|
||||
<xsl:for-each select="report/product/pro" >
|
||||
<tr>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@categ">
|
||||
<td> <para style="categ"><xsl:value-of select="attribute::name" /> </para> </td>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<td> <para style="product1"> <xsl:value-of select="attribute::name" /> </para> </td>
|
||||
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:for-each select="price" >
|
||||
<td><para style="price"> <xsl:value-of select="attribute::name" /> </para> </td>
|
||||
</xsl:for-each>
|
||||
</tr>
|
||||
</xsl:for-each>
|
||||
</blockTable>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
Loading…
Reference in New Issue