1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU Affero General Public License as
9
# published by the Free Software Foundation, either version 3 of the
10
# License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Affero General Public License for more details.
17
# You should have received a copy of the GNU Affero General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
##############################################################################
24
from report import report_sxw
27
class account_invoice_1(report_sxw.rml_parse):
28
def __init__(self, cr, uid, name, context):
30
super(account_invoice_1, self).__init__(cr, uid, name, context=context)
31
self.localcontext.update({
33
'invoice_lines': self.invoice_lines,
35
self.context = context
38
def invoice_lines(self, invoice):
45
ids = self.pool.get('account.invoice.line').search(self.cr, self.uid, [('invoice_id', '=', invoice.id)])
47
for id in range(0, len(ids)):
48
info = self.pool.get('account.invoice.line').browse(self.cr, self.uid, ids[id], self.context.copy())
49
list_in_seq[info] = info.sequence
52
final=sorted(list_in_seq.items(), lambda x, y: cmp(x[1], y[1]))
53
invoice_list = [x[0] for x in final]
56
for entry in invoice_list:
58
if entry.state == 'article':
59
self.cr.execute('select tax_id from account_invoice_line_tax where invoice_line_id=%s', (entry.id,))
60
tax_ids = self.cr.fetchall()
65
for item in range(0, len(tax_ids)):
66
self.cr.execute('select name from account_tax where id=%s', (tax_ids[item][0],))
67
type = self.cr.fetchone()
68
tax_names_dict[item] = type[0]
69
tax_names = ','.join([tax_names_dict[x] for x in range(0, len(tax_names_dict))])
70
res['tax_types'] = tax_names
71
res['name'] = entry.name
72
res['quantity'] = self.formatLang(entry.quantity, digits=self.get_digits(dp='Account'))
73
res['price_unit'] = self.formatLang(entry.price_unit, digits=self.get_digits(dp='Account'))
74
res['discount'] = self.formatLang(entry.discount, digits=self.get_digits(dp='Account'))
75
res['price_subtotal'] = self.formatLang(entry.price_subtotal, digits=self.get_digits(dp='Account'))
76
sub_total[i] = entry.price_subtotal
78
res['note'] = entry.note
79
res['currency'] = invoice.currency_id.symbol
80
res['type'] = entry.state
82
if entry.uos_id.id == False:
85
uos_name = self.pool.get('product.uom').read(self.cr, self.uid, entry.uos_id.id, ['name'], self.context.copy())
86
res['uos'] = uos_name['name']
89
res['price_unit'] = ''
92
res['type'] = entry.state
93
res['note'] = entry.note
96
if entry.state == 'subtotal':
97
res['name'] = entry.name
100
if sum_flag[j] == -1:
105
for sum_id in range(temp, len(sub_total)+1):
106
sum += sub_total[sum_id]
107
sum_flag[j+1] = sum_id +1
110
res['price_subtotal'] = "%.2f" % (sum)
111
res['currency'] = invoice.currency_id.symbol
113
res['price_unit'] = ''
115
res['tax_types'] = ''
117
elif entry.state == 'title':
118
res['name'] = entry.name
119
res['price_subtotal'] = ''
121
elif entry.state == 'text':
122
res['name'] = entry.name
123
res['price_subtotal'] = ''
125
elif entry.state == 'line':
126
res['quantity'] = '_______________'
127
res['price_unit'] = '______________'
128
res['discount'] = '____________'
129
res['tax_types'] = '____________________'
131
res['name'] = '_______________________________________________'
132
res['price_subtotal'] = '____________'
133
res['currency'] = '____'
134
elif entry.state == 'break':
135
res['type'] = entry.state
136
res['name'] = entry.name
137
res['price_subtotal'] = ''
140
res['name'] = entry.name
141
res['price_subtotal'] = ''
142
res['currency'] = invoice.currency_id.symbol
146
report_sxw.report_sxw('report.account.invoice.layout.us', 'account.invoice', 'addons/reports_address_us/report/report_account_invoice_layout_us.rml', parser=account_invoice_1)
147
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: