1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
24 from report import report_sxw
26 class account_invoice_1(report_sxw.rml_parse):
27 def __init__(self, cr, uid, name, context):
28 super(account_invoice_1, self).__init__(cr, uid, name, context)
29 self.localcontext.update({
31 'invoice_lines': self.invoice_lines,
33 self.context = context
36 def invoice_lines(self,invoice):
43 ids = self.pool.get('account.invoice.line').search(self.cr, self.uid, [('invoice_id', '=', invoice.id)])
45 for id in range(0,len(ids)):
46 info = self.pool.get('account.invoice.line').browse(self.cr, self.uid,ids[id], self.context.copy())
47 list_in_seq[info]=info.sequence
50 final=sorted(list_in_seq.items(), lambda x, y: cmp(x[1], y[1]))
51 invoice_list=[x[0] for x in final]
54 for entry in invoice_list:
56 if entry.state=='article':
57 self.cr.execute('select tax_id from account_invoice_line_tax where invoice_line_id=%s', (entry.id,))
58 tax_ids=self.cr.fetchall()
63 for item in range(0,len(tax_ids)) :
64 self.cr.execute('select name from account_tax where id=%s', (tax_ids[item][0],))
65 type=self.cr.fetchone()
66 tax_names_dict[item] =type[0]
67 tax_names = ','.join([tax_names_dict[x] for x in range(0,len(tax_names_dict))])
68 res['tax_types']=tax_names
69 res['name']=entry.name
70 res['quantity']="%.2f"%(entry.quantity)
71 res['price_unit']="%.2f"%(entry.price_unit)
72 res['discount']="%.2f"%(entry.discount)
73 res['price_subtotal']="%.2f"%(entry.price_subtotal)
74 sub_total[i]=entry.price_subtotal
76 res['note']=entry.note
77 res['currency']=invoice.currency_id.code
78 res['type']=entry.state
80 if entry.uos_id.id==False:
83 uos_name = self.pool.get('product.uom').read(self.cr,self.uid,entry.uos_id.id,['name'],self.context.copy())
84 res['uos'] = uos_name['name']
91 res['type']=entry.state
92 res['note']=entry.note
95 if entry.state=='subtotal':
96 res['name']=entry.name
104 for sum_id in range(temp,len(sub_total)+1):
105 sum+=sub_total[sum_id]
106 sum_flag[j+1]= sum_id +1
109 res['price_subtotal']="%.2f"%(sum)
110 res['currency']=invoice.currency_id.code
116 elif entry.state=='title':
117 res['name']=entry.name
118 res['price_subtotal']=''
120 elif entry.state=='text':
121 res['name']=entry.name
122 res['price_subtotal']=''
124 elif entry.state=='line':
125 res['quantity']='_______________'
126 res['price_unit']='______________'
127 res['discount']='____________'
128 res['tax_types']='____________________'
130 res['name']='_______________________________________________'
131 res['price_subtotal']='____________'
132 res['currency']='____'
133 elif entry.state=='break':
134 res['type']=entry.state
135 res['name']=entry.name
136 res['price_subtotal']=''
139 res['name']=entry.name
140 res['price_subtotal']=''
141 res['currency']=invoice.currency_id.code
145 report_sxw.report_sxw('report.account.invoice.layout', 'account.invoice', 'addons/account_invoice_layout/report/report_account_invoice_layout.rml', parser=account_invoice_1)
146 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: