[fix] problem in o2m
[odoo/odoo.git] / addons / auction / report / huissier.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6 #
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.
11 #
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.
16 #
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/>.
19 #
20 ##############################################################################
21
22 import pooler
23 from report.interface import report_rml
24 #FIXME: use the one from tools and delete the one from report
25 from report.int_to_text import int_to_text
26 from tools import to_xml as toxml
27 from tools import ustr
28
29 class report_custom(report_rml):
30     def __init__(self, name, table, tmpl, xsl):
31         report_rml.__init__(self, name, table, tmpl, xsl)
32
33     def create_xml(self,cr, uid, ids, datas, context=None):
34         pool= pooler.get_pool(cr.dbname)
35         lots = pool.get('auction.lots').browse(cr, uid, ids, context=context)
36         auction = lots[0].auction_id
37
38         xml = '''<?xml version="1.0" encoding="UTF-8"?>
39 <report>
40     <auction>
41         <name>%s</name>
42         <date-au1>%s</date-au1>
43     </auction>''' % (toxml(auction['name']), toxml(auction['auction1']))
44
45         i = 0
46         for l in lots:
47             if l['obj_price']==0:
48                 price_french = u'retirĂ©'
49             else:
50                 price_french = int_to_text(int(l['obj_price'] or 0.0))+' eur'
51             i+=1
52             xml += '''  <object>
53         <number>%d</number>
54         <obj_num>%d</obj_num>
55         <lot_desc>%s</lot_desc>
56         <price>%s</price>
57         <obj_price>%s</obj_price>
58     </object>''' % (i, l['obj_num'], ustr(toxml(l['name'])), ustr(price_french), ustr(l['obj_price'] or '/'))
59         xml += '</report>'
60
61         return xml
62
63 report_custom('report.flagey.huissier', 'auction.lots', '', 'addons/auction/report/huissier.xsl')
64
65
66 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
67