1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2009 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
##############################################################################
23
from report import report_sxw
25
class pos_payment_report_user(report_sxw.rml_parse):
27
def __init__(self, cr, uid, name, context):
28
super(pos_payment_report_user, self).__init__(cr, uid, name, context)
30
self.localcontext.update({
32
'pos_payment_user': self.__pos_payment_user__,
33
'pos_payment_user_total':self.__pos_payment_user__total__,
36
def __pos_payment_user__(self,form):
38
ids = form['user_id'][0][-1]
40
sql = "select pt.name,pol.qty,pol.discount,pol.price_unit, " \
41
"(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0)) as total " \
42
"from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt " \
43
"where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id " \
44
"and po.state in ('paid','invoiced') and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date = current_date " \
45
"and po.user_id in (%s)" % (",".join(idss), )
47
data=self.cr.dictfetchall()
49
def __pos_payment_user__total__(self,form):
51
ids = form['user_id'][0][-1]
53
self.cr.execute ("select sum(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0)) " \
54
"from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt " \
55
"where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id " \
56
"and po.state='paid' and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date = current_date " \
57
"and po.user_id in (%s)" % (",".join(idss), ))
58
res=self.cr.fetchone()
59
res = res and res[0] or None
64
report_sxw.report_sxw('report.pos.payment.report.user', 'pos.order', 'addons/point_of_sale/report/pos_payment_report_user.rml', parser=pos_payment_report_user)