1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # Copyright (c) 2005 TINY SPRL. (http://tiny.be) All Rights Reserved.
8 # WARNING: This program as such is intended to be used by professional
9 # programmers who take the whole responsability of assessing all potential
10 # consequences resulting from its eventual inadequacies and bugs
11 # End users who are looking for a ready-to-use solution with commercial
12 # garantees and support are strongly adviced to contract a Free Software
15 # This program is Free Software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License
17 # as published by the Free Software Foundation; either version 2
18 # of the License, or (at your option) any later version.
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 ##############################################################################
34 from report import report_sxw
37 class auction_total_rml(report_sxw.rml_parse):
39 def __init__(self, cr, uid, name, context):
40 super(auction_total_rml, self).__init__(cr, uid, name, context)
41 self.localcontext.update({
43 'sum_taxes':self.sum_taxes,
44 'sold_item':self.sold_item,
45 'sum_buyer':self.sum_buyer,
46 'sum_seller':self.sum_seller,
47 'sum_buyer_paid':self.sum_buyer_paid,
48 'sum_adj':self.sum_adj,
49 'count_comm':self.count_comm,
50 'sum_minadj':self.sum_minadj,
51 'sum_maxadj':self.sum_maxadj,
52 'sum_credit':self.sum_credit,
53 'sum_debit': self.sum_debit,
54 'chek_paid': self.chek_paid,
55 'check_paid_seller': self.check_paid_seller,
56 'count_take': self.count_take,
57 'sum_credit_seller':self.sum_credit_seller,
58 'sum_debit_buyer': self.sum_debit_buyer,
59 'get_auc_detail': self.get_auc_detail
61 def get_auc_detail(self,objects):
63 for lot_id in objects:
64 auc_lot_ids.append(lot_id.id)
65 self.total_obj=auc_lot_ids
66 self.cr.execute('select auction_id from auction_lots where id in ('+','.join(map(str,auc_lot_ids))+') group by auction_id')
67 auc_date_ids = self.cr.fetchall()
69 for ad_id in auc_date_ids:
70 auc_dates_fields = self.pool.get('auction.dates').read(self.cr,self.uid,ad_id[0],['name','auction1','id'])
71 auct_dat.append(auc_dates_fields)
75 def sum_taxes(self,auction_id):
76 self.cr.execute("select count(1) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d group by auction_id "%(auction_id))
77 res = self.cr.fetchone()
78 print "GGGGGGGGGgg",res[0]
80 def sold_item(self, object_id):
81 self.cr.execute("select count(1) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d and state in ('unsold') "%(object_id,))
82 res = self.cr.fetchone()
87 def sum_buyer(self, auction_id):
88 self.cr.execute("select count(*) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d and (ach_uid is not null or ach_login is not null) "%(auction_id))
89 res = self.cr.fetchone()
93 def sum_seller(self, auction_id):
94 self.cr.execute("select count(distinct bord_vnd_id) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d AND bord_vnd_id is not null "%(auction_id))
95 res = self.cr.fetchone()
98 def sum_adj(self, auction_id):
99 self.cr.execute("select sum(obj_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d "%(auction_id))
100 res = self.cr.fetchone()
103 def count_take(self, auction_id):
104 self.cr.execute("select count(*) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d and ach_emp='True' "%(auction_id))
105 res = self.cr.fetchone()
108 def chek_paid(self, auction_id):
109 self.cr.execute("select count(1) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d and ((paid_ach='T') or (is_ok='T')) "%(auction_id))
110 res = self.cr.fetchone()
112 def check_paid_seller(self,auction_id):
114 self.cr.execute("select sum(seller_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d and paid_vnd != 'T' "%(auction_id))
115 res = self.cr.fetchone()
116 print ">>>>>>>>>>>>>>",res
117 return str(res[0]) or 0.0
119 def sum_credit(self,auction_id):
120 print "object",auction_id
122 self.cr.execute("select sum(buyer_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d "%(auction_id))
123 res = self.cr.fetchone()
126 def sum_debit_buyer(self,auction_id):
127 self.cr.execute("select sum(buyer_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d "%(auction_id))
128 res = self.cr.fetchone()
129 return str(res[0] or 0)
131 def sum_debit(self,object_id):
132 self.cr.execute("select sum(seller_price) from auction_lots where auction_id=%d "%(object_id,))
133 res = self.cr.fetchone()
134 return str(res[0] or 0)
136 def sum_credit_seller(self, object_id):
139 self.cr.execute("select sum(seller_price) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d "%(object_id))
140 res = self.cr.fetchone()
141 return str(res[0] or 0)
143 def sum_minadj(self, auction_id):
144 self.cr.execute('select sum(lot_est1) from auction_lots where id in ('+','.join(map(str,self.total_obj))+') and auction_id=%d '%(auction_id))
145 res = self.cr.fetchone()
146 print "min est",res[0]
147 return str(res[0]) or 0
149 def sum_maxadj(self, auction_id):
150 self.cr.execute('select sum(lot_est2) from auction_lots where id in ('+','.join(map(str,self.total_obj))+') and auction_id=%d '%(auction_id))
151 res = self.cr.fetchone()
152 return str(res[0]) or 0
154 def sum_buyer_paid(self, auction_id):
155 self.cr.execute("select count(*) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d and state = 'paid' "%(auction_id))
156 res = self.cr.fetchone()
159 def count_comm(self, auction_id):
160 self.cr.execute("select count(*) from auction_lots where id in ("+",".join(map(str,self.total_obj))+") and auction_id=%d and obj_comm is not null "%(auction_id))
161 res = self.cr.fetchone()
165 report_sxw.report_sxw('report.auction.total.rml', 'auction.lots', 'addons/auction/report/auction_total.rml',parser=auction_total_rml)
168 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: