# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # ############################################################################## import time import netsvc from report.interface import report_rml def toxml(val): return val.replace('&', '&').replace('<','<').replace('>','>').decode('utf-8').encode('latin1') class report_custom(report_rml): def __init__(self, name, table, tmpl, xsl): report_rml.__init__(self, name, table, tmpl, xsl) def create_xml(self, cr, uid, ids, datas, context=None): service = netsvc.LocalService("object_proxy") lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', ids, ['obj_price','ach_login','obj_comm','lot_est1','lot_est2','bord_vnd_id','ach_emp','auction_id']) auction = service.execute(cr.dbname, uid, 'auction.dates', 'read', [lots[0]['auction_id'][0]])[0] unsold = comm = emp = paid = unpaid = 0 est1 = est2 = adj = 0 paid_ids = [] unpaid_ids = [] buyer = {} seller = {} for l in lots: if l['lot_est2']: est2 += l['lot_est2'] or 0.0 if l['lot_est1']: est1 += l['lot_est1'] or 0.0 if l['obj_price']: adj += l['obj_price'] or 0.0 if l['obj_comm']: comm += 1 if l['ach_emp']: emp += 1 if l['ach_pay_id']: paid_ids.append(l['id']) paid += l['obj_price'] else: unpaid_ids.append(l['id']) unpaid += l['obj_price'] if l['obj_price']==0: unsold+=1 buyer[l['ach_login']]=1 seller[l['bord_vnd_id']]=1 debit = adj costs = service.execute(cr.dbname, uid, 'auction.lots', 'compute_seller_costs', ids) for cost in costs: debit += cost['amount'] xml = ''' %s %s %s %d %.2f %.2f %d %.2f %d %d %d %d %.2f %.2f %d %.2f ''' % (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) return self.post_process_xml_data(cr, uid, xml, context) report_custom('report.auction.total', 'auction.lots', '', 'addons/auction/report/total.xsl') # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: