1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2008 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
28
('none', 'Non Member'),
29
('canceled', 'Canceled Member'),
30
('old', 'Old Member'),
31
('waiting', 'Waiting Member'),
32
('invoiced', 'Invoiced Member'),
33
('associated', 'Associated Member'),
34
('free', 'Free Member'),
35
('paid', 'Paid Member'),
38
class account_invoice_draft(report_sxw.rml_parse):
39
def __init__(self, cr, uid, name, context):
40
super(account_invoice_draft, self).__init__(cr, uid, name, context)
41
self.localcontext.update({
43
'partner_objects':self.partner_objects,
44
'member_type':self.member_type,
45
'nationality':self.nationality,
47
'sum_amt_untaxed':self.sum_amt_untaxed,
48
'sum_amt_tax':self.sum_amt_tax,
49
'sum_total':self.sum_total,
55
def partner_objects(self,ids={}):
58
partner_objects = pooler.get_pool(self.cr.dbname).get('res.partner').browse(self.cr, self.uid, ids)
59
return partner_objects
61
def member_type(self, object):
62
membership=object.membership_state
63
for member_type in STATE:
64
if membership==member_type[0]:
65
membership=member_type[1]
69
def nationality(self, object):
70
nationality='Not Mentioned'
72
for ads in object.address:
73
if ads.type=='default':
75
if ads.country_id.code=='BE':
78
nationality='Non-Belgian'
82
def lines(self, object):
84
obj_inv=pooler.get_pool(self.cr.dbname).get('account.invoice')
85
list_ids=obj_inv.search(self.cr,self.uid,[('state','=','draft'),('partner_id','=',object.id),('type','=','out_invoice')])
86
invoices=obj_inv.browse(self.cr,self.uid,list_ids)
91
for invoice in invoices:
92
self.sum_untaxed +=invoice.amount_untaxed
94
self.sum_tax +=invoice.amount_tax
96
self.sum_tot +=invoice.amount_total
98
if not invoice.invoice_line:
101
for line in invoice.invoice_line:
104
res['name']=line.name
105
res['date']=invoice.date_invoice
106
untaxed=line.price_unit * line.quantity
107
discounted=(untaxed) * line.discount / 100
109
res['amt_untaxed']=(untaxed) - discounted
110
tax_info=pooler.get_pool(self.cr.dbname).get('account.tax').compute(self.cr,self.uid,line.invoice_line_tax_id, line.price_unit,line.quantity)
113
for record in tax_info:
114
taxed += record['amount']
117
res['total']=untaxed - discounted + taxed
118
res['gen_acc']=line.account_id.name
119
res['analytic_acc']=line.account_analytic_id and line.account_analytic_id.name or '-'
123
def sum_amt_untaxed(self):
124
return self.sum_untaxed
126
def sum_amt_tax(self):
132
report_sxw.report_sxw('report.partner.draft_invoices', 'res.partner', 'addons/cci_account/report/cci_draft_invoice_info.rml', parser=account_invoice_draft,header=False)
133
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: