Bugfix[375034]:account_invoice_layout

bzr revid: nch@tinyerp.com-20090512112305-an22i0tk5rykn8ux
This commit is contained in:
Naresh Choksy
2009-05-12 16:53:05 +05:30
parent b66c44f965
commit 4ea53181bb
2 changed files with 83 additions and 138 deletions
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@@ -23,79 +23,17 @@ import time
import pooler
from report import report_sxw
parents = {
'tr':1,
'li':1,
'story': 0,
'section': 0
}
class account_invoice_1(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(account_invoice_1, self).__init__(cr, uid, name, context)
self.localcontext.update({
'time': time,
'invoice_lines': self.invoice_lines,
'repeat_In':self.repeat_In,
})
self.context = context
def repeat_In(self, lst, name, nodes_parent=False,td=False,width=[],value=[],type=[]):
self._node.data = ''
node = self._find_parent(self._node, nodes_parent or parents)
ns = node.nextSibling
value=['tax_types','quantity','uos','price_unit','discount','price_subtotal','currency']
type=['string','string','string','string','string','string','string']
width=[62,38,29,67,53,53,27]
td=7
tableFlag=0
if not lst:
lst.append(1)
for ns in node.childNodes :
if tableFlag==1:
break
if ns and ns.nodeName!='#text' and ns.tagName=='blockTable' and td :
tableFlag=1
width_str = ns._attrs['colWidths'].nodeValue
ns.removeAttribute('colWidths')
total_td = td * len(value)
if not width:
for v in value:
width.append(30)
for v in range(len(value)):
width_str +=',%d'%width[v]
ns.setAttribute('colWidths',width_str)
child_list = ns.childNodes
for child in child_list:
if child.nodeName=='tr':
lc = child.childNodes[1]
# for t in range(td):
i=0
for v in value:
t2="[[%s['type']=='text' and removeParentNode('tr')]]"%(name)
t1= "[[ %s['%s'] ]]"%(name,v)
t3="[[ %s['type']=='subtotal' and ( setTag('para','para',{'fontName':'Times-bold'})) ]]"%name
newnode = lc.cloneNode(1)
newnode.childNodes[1].lastChild.data = t1 + t2 +t3
# newnode.childNodes[1].lastChild.data=[[ a['status']==1 and ( setTag('para','para',{'fontName':'Times-bold'})) ]]
child.appendChild(newnode)
newnode=False
i+=1
return super(account_invoice_1,self).repeatIn(lst, name, nodes_parent=False)
self._node = None
def invoice_lines(self,invoice):
result =[]
sub_total={}
info=[]
@@ -107,7 +45,6 @@ class account_invoice_1(report_sxw.rml_parse):
for id in range(0,len(ids)):
info = self.pool.get('account.invoice.line').browse(self.cr, self.uid,ids[id], self.context.copy())
list_in_seq[info]=info.sequence
# invoice_list +=[info]
i=1
j=0
final=sorted(list_in_seq.items(), lambda x, y: cmp(x[1], y[1]))
@@ -116,11 +53,9 @@ class account_invoice_1(report_sxw.rml_parse):
sum_flag[j]=-1
for entry in invoice_list:
res={}
if entry.state=='article':
self.cr.execute('select tax_id from account_invoice_line_tax where invoice_line_id=%s', (entry.id,))
tax_ids=self.cr.fetchall()
if tax_ids==[]:
res['tax_types']=''
else:
@@ -187,14 +122,14 @@ class account_invoice_1(report_sxw.rml_parse):
res['price_subtotal']=''
res['currency']=''
elif entry.state=='line':
res['quantity']='____________'
res['quantity']='_______________'
res['price_unit']='______________'
res['discount']='____________'
res['tax_types']='_________________'
res['tax_types']='____________________'
res['uos']='_____'
res['name']='________________________________________'
res['price_subtotal']='_______________________'
res['currency']='_______'
res['name']='_______________________________________________'
res['price_subtotal']='____________'
res['currency']='____'
elif entry.state=='break':
res['type']=entry.state
res['name']=entry.name
@@ -130,8 +130,7 @@
<font color="white"> </font>
</para>
<para style="P17">
<font face="Times-Roman">Document</font>
<font face="Times-Roman">:</font>
<font face="Times-Roman">Document:</font>
<font face="Times-Roman">[[o.name]]</font>
</para>
<para style="P17">
@@ -143,7 +142,7 @@
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="198.0,62.0,67.0,67.0,53.0,80.0" style="Tableau6">
<blockTable colWidths="216.0,62.0,62.0,62.0,51.0,74.0" style="Tableau6">
<tr>
<td>
<para style="P3">Description</para>
@@ -166,64 +165,80 @@
</tr>
</blockTable>
<section>
<para style="P20">[[ repeat_In(invoice_lines(o), 'a') ]]</para>
<blockTable colWidths="0.0,198.0" style="Tableau7">
<tr>
<td>
<para style="P8">[[ a['type']=='text' and removeParentNode('tr')]]</para>
</td>
<td>
<para style="Table Contents"><font>[[ a['type']=='title' and ( setTag('font','font',{'size':'11.5'})) ]][[ (a['type']=='title' or a['type']=='subtotal') and ( setTag('font','font',{'name':'Times-bold'})) ]][[ a['type']=='text' and removeParentNode('font') or a['name'] ]]</font></para>
</td>
</tr>
</blockTable>
<blockTable colWidths="447.0,80.0" style="Tableau8">
<tr>
<td>
<para style="Table Contents">[[ a['type']=='text' and a['name'] or removeParentNode('table') ]]</para>
</td>
<td>
<para style="P8">[[ a['type']=='text' and '' or removeParentNode('table') ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="28.0,499.0" style="Tableau8">
<tr>
<td>
<para style="P21">[[ a['note']=='' and removeParentNode('table') ]][[ repeatIn(( a['note'] and a['note'].splitlines()) or [], 'note') ]]</para>
</td>
<td>
<para style="P9">[[ note or removeParentNode('table') ]]</para>
</td>
</tr>
</blockTable>
<pageBreak>[[ a['type']!='break' and removeParentNode('pageBreak')]]</pageBreak>
<blockTable colWidths="198.0,62.0,67.0,67.0,53.0,80.0" style="Tableau6">
<tr>
<td>
<para style="P3">Description [[ a['type']!='break' and removeParentNode('tr')]]</para>
</td>
<td>
<para style="P4">Taxes</para>
</td>
<td>
<para style="P4">Quantity</para>
</td>
<td>
<para style="P4">Unit Price</para>
</td>
<td>
<para style="P4">Disc. (%)</para>
</td>
<td>
<para style="P4">Price</para>
</td>
</tr>
</blockTable>
<para style="P20">[[ repeatIn(invoice_lines(o), 'a') ]]</para>
<blockTable colWidths="0.0,216.0,62,38,29,67,53,53" style="Tableau7">
<tr>
<td>
<para style="P8">[[ a['type']=='text' and removeParentNode('tr')]]</para>
</td>
<td>
<para style="Table Contents">[[ (a['type']=='title' or a['type']=='subtotal') and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ a['name'] ]]</para>
</td>
<td>
<para style="Table Contents">[[ a['type']=='subtotal' and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ a['tax_types'] ]]</para>
</td>
<td>
<para style="Table Contents">[[ a['type']=='subtotal' and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ a['quantity'] ]]</para>
</td>
<td>
<para style="Table Contents">[[ a['type']=='subtotal' and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ a['uos'] ]]</para>
</td>
<td>
<para style="Table Contents">[[ a['type']=='subtotal' and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ a['price_unit'] ]]</para>
</td>
<td>
<para style="Table Contents">[[ a['type']=='subtotal' and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ a['discount'] ]]</para>
</td>
<td>
<para style="Table Contents">[[ a['type']=='subtotal' and ( setTag('para','para',{'fontName':'Times-bold'})) ]][[ a['price_subtotal'] ]][[ a['currency'] ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="453.0,74.0" style="Tableau8">
<tr>
<td>
<para style="Table Contents">[[ a['type']=='text' and a['name'] or removeParentNode('blockTable') ]]</para>
</td>
<td>
<para style="P8">[[ a['type']=='text' and '' or removeParentNode('blockTable') ]]</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="28.0,499.0" style="Tableau8">
<tr>
<td>
<para style="P21"><font>[[ a['note']=='' and removeParentNode('blockTable') ]]</font><font>[[ repeatIn(( a['note'] and a['note'].splitlines()) or [], 'note') ]]</font></para>
</td>
<td>
<para style="P9">[[ note or removeParentNode('blockTable') ]]</para>
</td>
</tr>
</blockTable>
<pageBreak>[[ a['type']!='break' and removeParentNode('pageBreak')]]</pageBreak>
<blockTable colWidths="216.0,62.0,62.0,62.0,51.0,74.0" style="Tableau6">
<tr>
<td>
<para style="P3">Description [[ a['type']!='break' and removeParentNode('tr')]]</para>
</td>
<td>
<para style="P4">Taxes</para>
</td>
<td>
<para style="P4">Quantity</para>
</td>
<td>
<para style="P4">Unit Price</para>
</td>
<td>
<para style="P4">Disc. (%)</para>
</td>
<td>
<para style="P4">Price</para>
</td>
</tr>
</blockTable>
</section>
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="215.0,313.0" style="Tableau3">
<tr>
<td>
@@ -281,16 +296,11 @@
</td>
</tr>
</blockTable>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="P19">[[ format(o.comment) or '' ]]</para>
<para style="P19">
<font color="white"> </font>
</para>
<para style="P19">[[ format(o.payment_term and o.payment_term.note) or '' ]]</para>
</story>
</document>