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 ##############################################################################
25 from report.interface import report_rml
28 return val.replace('&', '&').replace('<','<').replace('>','>').decode('utf-8').encode('latin1')
30 class report_custom(report_rml):
31 def __init__(self, name, table, tmpl, xsl):
32 report_rml.__init__(self, name, table, tmpl, xsl)
34 def create_xml(self, cr, uid, ids, datas, context=None):
35 lots = self.pool.get('auction.lots').read(cr, uid , ids, ['obj_price','ach_login','obj_comm','lot_est1','lot_est2','bord_vnd_id','ach_emp','auction_id'])
36 auction = self.pool.get('auction.dates').read(cr, uid, [lots[0]['auction_id'][0]])[0]
38 unsold = comm = emp = paid = unpaid = 0
47 est2 += l['lot_est2'] or 0.0
50 est1 += l['lot_est1'] or 0.0
53 adj += l['obj_price'] or 0.0
62 paid_ids.append(l['id'])
63 paid += l['obj_price']
65 unpaid_ids.append(l['id'])
66 unpaid += l['obj_price']
71 buyer[l['ach_login']]=1
72 seller[l['bord_vnd_id']]=1
76 costs = self.pool.get('auction.lots').compute_seller_costs(cr, uid, ids)
78 debit += cost['amount']
81 xml = '''<?xml version="1.0" encoding="ISO-8859-1"?>
90 <est_min>%.2f</est_min>
91 <est_max>%.2f</est_max>
93 <obj_price>%.2f</obj_price>
97 <paid_nbr>%d</paid_nbr>
98 <comm_nbr>%d</comm_nbr>
99 <taken_nbr>%d</taken_nbr>
100 <credit>%.2f</credit>
104 <sell_nbr>%d</sell_nbr>
107 </report>''' % (time.strftime('%d/%m/%Y'), toxml(auction['name']), auction['auction1'], len(lots), est1, est2, unsold, adj, len(buyer), len(paid_ids), comm, emp, unpaid, paid, len(seller), debit)
109 return self.post_process_xml_data(cr, uid, xml, context)
111 report_custom('report.auction.total', 'auction.lots', '', 'addons/auction/report/total.xsl')
114 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: