[IMP] point_of_sale: Code clean and rename some file name

bzr revid: ara@tinyerp.com-20101027120701-7r63salifxf9hu91
This commit is contained in:
ARA (OpenERP)
2010-10-27 17:37:01 +05:30
parent 19f63661b2
commit f300ceb3dc
22 changed files with 77 additions and 562 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@@ -15,7 +15,7 @@
# 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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@@ -64,7 +64,7 @@ Main features :
'wizard/pos_return_view.xml',
'point_of_sale_report.xml',
'point_of_sale_view.xml',
'report/report_pos_order_view.xml',
'report/pos_order_report_view.xml',
'report/report_cash_register_view.xml',
'point_of_sale_sequence.xml',
'point_of_sale_workflow.xml',
+5 -5
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@@ -15,7 +15,7 @@
# 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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@@ -35,8 +35,8 @@ import pos_payment_report_user
import pos_sales_user_today_current_user
import pos_receipt_with_remboursment
import pos_receipt_without_remboursment
import point_of_sale_report
import report_pos_order
import pos_report
import pos_order_report
import report_cash_register
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -22,7 +22,6 @@
import time
from report import report_sxw
class account_statement(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
@@ -30,8 +29,8 @@ class account_statement(report_sxw.rml_parse):
self.total = 0.0
self.localcontext.update({
'time': time,
'get_total':self._get_total,
'get_data':self._get_data,
'get_total': self._get_total,
'get_data': self._get_data,
})
def _get_data(self, statement):
@@ -49,3 +48,4 @@ class account_statement(report_sxw.rml_parse):
report_sxw.report_sxw('report.account.statement', 'account.bank.statement', 'addons/statement/report/account_statement.rml', parser=account_statement,header='internal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -22,7 +22,6 @@
import time
from report import report_sxw
class all_closed_cashbox_of_the_day(report_sxw.rml_parse):
#TOFIX: sql injection problem: SQL Request must be pass from sql injection...
def __init__(self, cr, uid, name, context):
@@ -38,6 +37,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse):
'get_sub_total':self._get_sub_total,
'get_net_total_starting':self._get_net_total_starting,
})
def _get_user(self,line_ids):
sql = "select name from res_users where id = %d"%(line_ids['create_uid'])
self.cr.execute(sql)
@@ -70,9 +70,9 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse):
sql =""" select sum(pieces*number) as bal from account_cashbox_line where starting_id = %d """%(data['id'])
self.cr.execute(sql)
res = self.cr.dictfetchall()
if res :
if res:
return res[0]['bal']
else :
else:
return False
def _get_sub_total(self,user,data,date):
@@ -89,6 +89,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse):
return res[0][0]
else:
return False
def _get_partner(self,statement):
res = {}
if statement['pos_statement_id']:
@@ -98,10 +99,9 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse):
self.cr.execute(sql)
res = self.cr.dictfetchall() or {}
return res and res[0]['name']
else :
else:
return 0.00
def _get_net_total_starting(self,user):
lst = []
res={}
@@ -113,7 +113,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse):
and abs.user_id = %d"""%(user.id)
self.cr.execute(sql)
res = self.cr.dictfetchall()
for r in res :
for r in res:
total_ending_bal += (r['net_total'] or 0.0)
sql1 =""" select sum(pieces*number) as bal from account_cashbox_line where starting_id = %d"""%(r['id'])
self.cr.execute(sql1)
@@ -136,3 +136,5 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse):
return res[0]['net_total'] or 0.0
report_sxw.report_sxw('report.all.closed.cashbox.of.the.day', 'account.bank.statement', 'addons/point_of_sale/report/all_closed_cashbox_of_the_day.rml', parser=all_closed_cashbox_of_the_day,header='internal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,238 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, fields
import time
import netsvc
import tools
class report_transaction_pos(osv.osv):
_name = "report.transaction.pos"
_description = "transaction for the pos"
_auto = False
_columns = {
'date_create': fields.char('Date', size=16, readonly=True),
'journal_id': fields.many2one('account.journal', 'Sales Journal', readonly=True),
'jl_id': fields.many2one('account.journal', 'Cash Journals', readonly=True),
'user_id': fields.many2one('res.users', 'User', readonly=True),
'no_trans': fields.float('Number of Transaction', readonly=True),
'amount': fields.float('Amount', readonly=True),
'invoice_id': fields.float('Nbr Invoice', readonly=True),
'invoice_am': fields.float('Invoice Amount', readonly=True),
'product_nb': fields.float('Product Nb.', readonly=True),
'disc': fields.float('Disc.', readonly=True),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_transaction_pos')
cr.execute("""
create or replace view report_transaction_pos as (
select
min(absl.id) as id,
count(absl.id) as no_trans,
sum(absl.amount) as amount,
sum(line.price_ded) as disc,
to_char(date_trunc('day',absl.create_date),'YYYY-MM-DD')::text as date_create,
po.user_id as user_id,
po.sale_journal as journal_id,
abs.journal_id as jl_id,
count(po.invoice_id) as invoice_id,
count(p.id) as product_nb
from
account_bank_statement_line as absl,
account_bank_statement as abs,
product_product as p,
pos_order_line as line,
pos_order as po
where
absl.pos_statement_id = po.id and
line.order_id=po.id and
line.product_id=p.id and
absl.statement_id=abs.id
group by
po.user_id,po.sale_journal, abs.journal_id,
to_char(date_trunc('day',absl.create_date),'YYYY-MM-DD')::text
)
""")
#to_char(date_trunc('day',absl.create_date),'YYYY-MM-DD')
#to_char(date_trunc('day',absl.create_date),'YYYY-MM-DD')::text as date_create,
report_transaction_pos()
class report_sales_by_user_pos(osv.osv):
_name = "report.sales.by.user.pos"
_description = "Sales by user"
_auto = False
_columns = {
'date_order': fields.date('Order Date',required=True, select=True),
'amount': fields.float('Total', readonly=True, select=True),
'qty': fields.float('Quantity', readonly=True, select=True),
'user_id': fields.many2one('res.users', 'User', readonly=True, select=True),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_sales_by_user_pos')
cr.execute("""
create or replace view report_sales_by_user_pos as (
select
min(po.id) as id,
to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::text as date_order,
po.user_id as user_id,
sum(pol.qty)as qty,
sum((pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))) as amount
from
pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt
where
pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id
group by
to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::text,
po.user_id
)
""")
report_sales_by_user_pos()
class report_sales_by_user_pos_month(osv.osv):
_name = "report.sales.by.user.pos.month"
_description = "Sales by user monthly"
_auto = False
_columns = {
'date_order': fields.date('Order Date',required=True, select=True),
'amount': fields.float('Total', readonly=True, select=True),
'qty': fields.float('Quantity', readonly=True, select=True),
'user_id': fields.many2one('res.users', 'User', readonly=True, select=True),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_sales_by_user_pos_month')
cr.execute("""
create or replace view report_sales_by_user_pos_month as (
select
min(po.id) as id,
to_char(date_trunc('month',po.date_order),'YYYY-MM-DD')::text as date_order,
po.user_id as user_id,
sum(pol.qty)as qty,
sum((pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))) as amount
from
pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt
where
pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id
group by
to_char(date_trunc('month',po.date_order),'YYYY-MM-DD')::text,
po.user_id
)
""")
report_sales_by_user_pos_month()
class report_sales_by_margin_pos(osv.osv):
_name = "report.sales.by.margin.pos"
_description = "Sales by margin"
_auto = False
_columns = {
'product_name':fields.char('Product Name', size=64, readonly=True),
'date_order': fields.date('Order Date',required=True, select=True),
'user_id': fields.many2one('res.users', 'User', readonly=True, select=True),
'qty': fields.float('Qty', readonly=True, select=True),
'net_margin_per_qty':fields.float('Net margin per Qty', readonly=True, select=True),
'total':fields.float('Margin', readonly=True, select=True),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_sales_by_margin_pos')
cr.execute("""
create or replace view report_sales_by_margin_pos as (
select
min(pol.id) as id,
po.user_id as user_id,
pt.name as product_name,
to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::text as date_order,
sum(pol.qty) as qty,
pt.list_price-pt.standard_price as net_margin_per_qty,
(pt.list_price-pt.standard_price) *sum(pol.qty) as total
from
product_template as pt,
product_product as pp,
pos_order_line as pol,
pos_order as po
where
pol.product_id = pp.product_tmpl_id and
pp.product_tmpl_id = pt.id and
po.id = pol.order_id
group by
pt.name,
pt.list_price,
pt.standard_price,
po.user_id,
to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::text
)
""")
report_sales_by_margin_pos()
class report_sales_by_margin_pos_month(osv.osv):
_name = "report.sales.by.margin.pos.month"
_description = "Sales by margin monthly"
_auto = False
_columns = {
'product_name':fields.char('Product Name', size=64, readonly=True),
'date_order': fields.date('Order Date',required=True, select=True),
'user_id': fields.many2one('res.users', 'User', readonly=True, select=True),
'qty': fields.float('Qty', readonly=True, select=True),
'net_margin_per_qty':fields.float('Net margin per Qty', readonly=True, select=True),
'total':fields.float('Margin', readonly=True, select=True),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_sales_by_margin_pos_month')
cr.execute("""
create or replace view report_sales_by_margin_pos_month as (
select
min(pol.id) as id,
po.user_id as user_id,
pt.name as product_name,
to_char(date_trunc('month',po.date_order),'YYYY-MM-DD')::text as date_order,
sum(pol.qty) as qty,
pt.list_price-pt.standard_price as net_margin_per_qty,
(pt.list_price-pt.standard_price) *sum(pol.qty) as total
from
product_template as pt,
product_product as pp,
pos_order_line as pol,
pos_order as po
where
pol.product_id = pp.product_tmpl_id and
pp.product_tmpl_id = pt.id and
po.id = pol.order_id
group by
pt.name,
pt.list_price,
pt.standard_price,
po.user_id,
to_char(date_trunc('month',po.date_order),'YYYY-MM-DD')::text
)
""")
report_sales_by_margin_pos_month()
+17 -18
View File
@@ -22,7 +22,6 @@
import time
from report import report_sxw
class pos_details(report_sxw.rml_parse):
def _get_invoice(self,inv_id,user):
@@ -36,13 +35,13 @@ class pos_details(report_sxw.rml_parse):
def _pos_sales_details(self,form,user):
data={}
self.cr.execute ("select po.name as pos_name,po.date_order,pt.name ,pp.default_code as code,pol.qty,pu.name as uom,pol.price_unit,pol.discount,po.invoice_id,sum((pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))) as Total " \
self.cr.execute ("select po.name as pos_name,po.date_order,pt.name, pp.default_code as code,pol.qty,pu.name as uom,pol.price_unit,pol.discount,po.invoice_id,sum((pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))) as Total " \
"from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt,product_uom as pu,res_users as ru,res_company as rc " \
"where pt.id=pp.product_tmpl_id and pu.id=pt.uom_id and pp.id=pol.product_id and po.id = pol.order_id and po.state IN ('done','paid','invoiced') " \
"and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date >= %s and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date <= %s " \
"and po.user_id = ru.id and rc.id = %s and ru.id = %s " \
"group by po.name,pol.qty,po.date_order,pt.name,pp.default_code,pu.name,pol.price_unit,pol.discount,po.invoice_id " \
,(form['date_start'],form['date_end'],str(user.company_id.id),str(self.uid)))
,(form['date_start'],form['date_end'],str(user.company_id.id),str(self.uid)))
data=self.cr.dictfetchall()
if data:
for d in data:
@@ -59,13 +58,13 @@ class pos_details(report_sxw.rml_parse):
"where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id and po.state IN ('done','paid','invoiced') " \
" and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date >= %s and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date <= %s " \
"and po.user_id = ru.id and rc.id = %s and ru.id = %s " \
,(form['date_start'],form['date_end'],str(user.company_id.id),str(self.uid)))
,(form['date_start'],form['date_end'],str(user.company_id.id),str(self.uid)))
qty = self.cr.fetchone()
return qty[0] or 0.00
def _get_sales_total_2(self, form,user):
self.cr.execute("select sum((pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))) as Total " \
"from pos_order_line as pol , pos_order po, product_product as pp,product_template as pt " \
"from pos_order_line as pol, pos_order po, product_product as pp,product_template as pt " \
" where po.company_id='%s' and po.id=pol.order_id and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date >= '%s' " \
" and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date <= '%s' and po.state IN ('paid','invoiced','done') " \
" and pt.id=pp.product_tmpl_id and pol.product_id=pp.id"% (str(user.company_id.id),form['date_start'],form['date_end']))
@@ -75,11 +74,11 @@ class pos_details(report_sxw.rml_parse):
def _get_sum_invoice_2(self,form,user):
res2=[]
self.cr.execute ("select sum(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))" \
"from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt ,res_users as ru,res_company as rc,account_invoice as ai " \
"from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt, res_users as ru,res_company as rc,account_invoice as ai " \
"where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id and ai.id=po.invoice_id " \
"and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date >= %s and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date <= %s " \
"and po.user_id = ru.id and rc.id = %s and ru.id = %s " \
,(form['date_start'],form['date_end'],str(user.company_id.id),str(self.uid)))
,(form['date_start'],form['date_end'],str(user.company_id.id),str(self.uid)))
res2=self.cr.fetchone()
self.total_invoiced=res2[0]
return res2[0] or False
@@ -91,7 +90,7 @@ class pos_details(report_sxw.rml_parse):
"where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id and po.state IN ('paid','invoiced','done') " \
"and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date >= %s and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date <= %s " \
"and po.user_id = ru.id and rc.id = %s and ru.id = %s " \
,(form['date_start'],form['date_end'],str(user.company_id.id),str(self.uid)))
,(form['date_start'],form['date_end'],str(user.company_id.id),str(self.uid)))
res3=self.cr.fetchone()
self.total_paid=res3[0]
return res3[0] or False
@@ -99,16 +98,15 @@ class pos_details(report_sxw.rml_parse):
def _get_sum_dis_2(self,form,user):
res4=[]
self.cr.execute ("select sum(pol.price_ded * pol.qty)" \
"from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt ,res_users as ru,res_company as rc " \
"from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt, res_users as ru,res_company as rc " \
"where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id and po.state IN ('paid') " \
"and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date >= %s and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date <= %s " \
"and po.user_id = ru.id and rc.id = %s and ru.id = %s " \
,(form['date_start'],form['date_end'],str(user.company_id.id),str(self.uid)))
,(form['date_start'],form['date_end'],str(user.company_id.id),str(self.uid)))
res4=self.cr.fetchone()
self.total_invoiced=res4[0]
return res4[0] or False
def _get_sum_discount(self, objects):
#code for the sum of discount value
return reduce(lambda acc, object:
@@ -122,14 +120,15 @@ class pos_details(report_sxw.rml_parse):
def _get_payments(self, form,user):
statement_line_obj = self.pool.get("account.bank.statement.line")
pos_ids=self.pool.get("pos.order").search(self.cr, self.uid, [('date_order','>=',form['date_start'] + ' 00:00:00'),('date_order','<=',form['date_end'] + ' 23:59:59'),('state','in',['paid','invoiced','done']),('user_id','=',self.uid)])
pos_order_obj = self.pool.get("pos.order")
pos_ids=pos_order_obj.search(self.cr, self.uid, [('date_order','>=',form['date_start'] + ' 00:00:00'),('date_order','<=',form['date_end'] + ' 23:59:59'),('state','in',['paid','invoiced','done']),('user_id','=',self.uid)])
data={}
if pos_ids:
st_line_ids = statement_line_obj.search(self.cr, self.uid, [('pos_statement_id', 'in', pos_ids)])
if st_line_ids:
st_id = statement_line_obj.browse(self.cr, self.uid, st_line_ids)
a_l=[]
for r in st_id :
for r in st_id:
a_l.append(r['id'])
self.cr.execute("select aj.name,sum(amount) from account_bank_statement_line as absl,account_bank_statement as abs,account_journal as aj " \
"where absl.statement_id = abs.id and abs.journal_id = aj.id and absl.id IN %s " \
@@ -142,7 +141,7 @@ class pos_details(report_sxw.rml_parse):
def _total_of_the_day(self, objects):
if self.total_paid:
if self.total_paid == self.total_invoiced :
if self.total_paid == self.total_invoiced:
return self.total_paid
else:
return ((self.total_paid or 0.00) - (self.total_invoiced or 0.00))
@@ -170,9 +169,10 @@ class pos_details(report_sxw.rml_parse):
temp={}
list_ids = []
temp2 = 0.0
pos_ids=self.pool.get("pos.order").search(self.cr, self.uid, [('date_order','>=',form['date_start'] + ' 00:00:00'),('date_order','<=',form['date_end'] + ' 23:59:59'),('state','in',['paid','invoiced','done']),('user_id','=',self.uid)])
pos_order_obj = self.pool.get("pos.order")
pos_ids = pos_order_obj.search(self.cr, self.uid, [('date_order','>=',form['date_start'] + ' 00:00:00'),('date_order','<=',form['date_end'] + ' 23:59:59'),('state','in',['paid','invoiced','done']),('user_id','=',self.uid)])
temp.update({'name':''})
for order in self.pool.get("pos.order").browse(self.cr, self.uid, pos_ids):
for order in pos_order_obj.browse(self.cr, self.uid, pos_ids):
temp2 +=order.amount_tax
for line in order.lines:
if len(line.product_id.taxes_id):
@@ -215,5 +215,4 @@ class pos_details(report_sxw.rml_parse):
report_sxw.report_sxw('report.pos.details', 'pos.order', 'addons/point_of_sale_singer/report/pos_details.rml', parser=pos_details, header='internal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -22,7 +22,6 @@
import time
from report import report_sxw
class pos_details_summary(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(pos_details_summary, self).__init__(cr, uid, name, context=context)
@@ -137,5 +136,4 @@ report_sxw.report_sxw('report.pos.details_summary',
parser=pos_details_summary,
header='internal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+1 -2
View File
@@ -24,7 +24,6 @@ from report import report_sxw
from osv import osv
from tools.translate import _
class pos_invoice(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
@@ -33,7 +32,6 @@ class pos_invoice(report_sxw.rml_parse):
'time': time,
})
def set_context(self, objects, data, ids, report_type=None):
super(pos_invoice, self).set_context(objects, data, ids, report_type)
iids = []
@@ -56,3 +54,4 @@ class pos_invoice(report_sxw.rml_parse):
report_sxw.report_sxw('report.pos.invoice', 'pos.order', 'addons/account/report/account_print_invoice.rml', parser= pos_invoice)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+2 -5
View File
@@ -22,7 +22,6 @@
import time
from report import report_sxw
class pos_lines(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
@@ -47,12 +46,10 @@ class pos_lines(report_sxw.rml_parse):
" LEFT JOIN pos_order_line as pol ON po.id = pol.order_id " \
" LEFT JOIN product_taxes_rel as ptr ON pol.product_id = ptr.prod_id " \
" LEFT JOIN account_tax as acct ON acct.id = ptr.tax_id " \
" WHERE pol.id = %s" ,(obj.id,))
" WHERE pol.id = %s", (obj.id,))
res=self.cr.fetchone()[0]
return res
report_sxw.report_sxw('report.pos.lines', 'pos.order', 'addons/point_of_sale/report/pos_lines.rml', parser=pos_lines,header='internal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -18,10 +18,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from report import report_sxw
class pos_payment_report(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
@@ -44,7 +44,7 @@ class pos_payment_report(report_sxw.rml_parse):
"where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id and pu.id=pt.uom_id " \
"and po.state IN ('paid','invoiced') and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date = current_date and po.id=%d"%(obj.id))
data=self.cr.dictfetchall()
else :
else:
self.cr.execute ("select pt.name,pp.default_code as code,pol.qty,pu.name as uom,pol.discount,pol.price_unit, " \
"(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0)) as total " \
"from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt, product_uom as pu " \
@@ -56,17 +56,9 @@ class pos_payment_report(report_sxw.rml_parse):
self.total += d['price_unit'] * d['qty']
return data
def _pos_payment_total(self,o):
return self.total
report_sxw.report_sxw('report.pos.payment.report', 'pos.order', 'addons/point_of_sale/report/pos_payment_report.rml', parser=pos_payment_report,header='internal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -18,10 +18,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from report import report_sxw
class pos_payment_report_date(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
@@ -43,14 +43,14 @@ class pos_payment_report_date(report_sxw.rml_parse):
"from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt,product_uom as pu " \
"where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id and pu.id=pt.uom_id " \
"and po.state IN ('paid','invoiced') and po.date_order >= %s and po.date_order <= %s and po.user_id IN %s " \
,(dt1,dt2,tuple(form['user_id'])))
,(dt1,dt2,tuple(form['user_id'])))
else:
self.cr.execute ("select pt.name,pp.default_code as code,pol.qty,pu.name as uom,pol.discount,pol.price_unit, " \
"(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0)) as total " \
"from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt,product_uom as pu " \
"where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id and pu.id=pt.uom_id " \
"and po.state IN ('paid','invoiced') and po.date_order >= %s and po.date_order <= %s" \
,(dt1,dt2))
,(dt1,dt2))
data=self.cr.dictfetchall()
return data
@@ -63,23 +63,17 @@ class pos_payment_report_date(report_sxw.rml_parse):
"from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt " \
"where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id " \
"and po.state IN ('paid','invoiced') and po.date_order >= %s and po.date_order <= %s and po.user_id IN %s " \
,(dt1,dt2,tuple(form['user_id'])))
,(dt1,dt2,tuple(form['user_id'])))
else:
self.cr.execute ("select sum(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0)) " \
"from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt " \
"where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id " \
"and po.state IN ('paid','invoiced') and po.date_order >= %s and po.date_order <= %s" \
,(dt1,dt2))
,(dt1,dt2))
res=self.cr.fetchone()[0] or 0.0
return res
report_sxw.report_sxw('report.pos.payment.report.date', 'pos.order', 'addons/point_of_sale/report/pos_payment_report_date.rml', parser=pos_payment_report_date,header='internal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from report import report_sxw
@@ -44,6 +45,7 @@ class pos_payment_report_user(report_sxw.rml_parse):
self.cr.execute (sql, (tuple(ids), ))
data=self.cr.dictfetchall()
return data
def __pos_payment_user__total__(self, form):
res=[]
ids = form['user_id']
@@ -57,21 +59,6 @@ class pos_payment_report_user(report_sxw.rml_parse):
return res
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,header='internal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+1 -2
View File
@@ -74,5 +74,4 @@ class order(report_sxw.rml_parse):
report_sxw.report_sxw('report.pos.receipt', 'pos.order', 'addons/point_of_sale/report/pos_receipt.rml', parser=order, header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -23,7 +23,6 @@ import time
from report import report_sxw
import pooler
class order(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
@@ -55,6 +54,7 @@ class order(report_sxw.rml_parse):
if line[0] != 0:
dsum = dsum +(line[2] * (line[0]*line[1]/100))
return dsum
def _get_journal_amt(self, order_id):
lst=[]
sql = """ select aj.name from account_bank_statement as abs
@@ -75,5 +75,4 @@ class order(report_sxw.rml_parse):
report_sxw.report_sxw('report.pos.receipt.with.remboursment', 'pos.order', 'addons/point_of_sale/report/pos_receipt_with_remboursment.rml', parser=order, header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -23,7 +23,6 @@ import time
from report import report_sxw
import pooler
class order(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
@@ -76,5 +75,4 @@ class order(report_sxw.rml_parse):
report_sxw.report_sxw('report.pos.receipt.without.remboursment', 'pos.order', 'addons/point_of_sale/report/pos_receipt_without_remboursment.rml', parser=order, header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -18,10 +18,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from report import report_sxw
class pos_sales_user(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
@@ -41,17 +41,11 @@ class pos_sales_user(report_sxw.rml_parse):
"from pos_order as po,res_users as ru,res_company as rc " \
"where po.date_order >= %s and po.date_order <= %s " \
"and po.company_id=rc.id and po.user_id=ru.id and po.user_id IN %s " \
,(dt1,dt2,tuple(form['user_id'])))
,(dt1,dt2,tuple(form['user_id'])))
data = self.cr.dictfetchall()
return data
report_sxw.report_sxw('report.pos.sales.user', 'pos.order', 'addons/point_of_sale/report/pos_sales_user.rml', parser=pos_sales_user,header='internal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -18,10 +18,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from report import report_sxw
class pos_sales_user_today(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
@@ -40,17 +40,11 @@ class pos_sales_user_today(report_sxw.rml_parse):
self.cr.execute("select po.name as pos,po.date_order,ru.name as user,po.state,rc.name " \
"from pos_order as po,res_users as ru,res_company as rc " \
"where to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date = current_date " \
"and po.company_id=rc.id and po.user_id=ru.id and po.user_id IN %s" ,(tuple(ids), ))
"and po.company_id=rc.id and po.user_id=ru.id and po.user_id IN %s", (tuple(ids), ))
data = self.cr.dictfetchall()
return data
report_sxw.report_sxw('report.pos.sales.user.today', 'pos.order', 'addons/point_of_sale/report/pos_sales_user_today.rml', parser=pos_sales_user_today,header='internal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -18,10 +18,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from report import report_sxw
class pos_sales_user_today_current_user(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
@@ -45,11 +45,11 @@ class pos_sales_user_today_current_user(report_sxw.rml_parse):
def _get_data_current_user(self, user):
data={}
self.cr.execute("select po.name,po. state,sum(pol.qty)as Qty,sum((pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))) as Total " \
"from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt ,res_users as ru,res_company as rc " \
"from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt, res_users as ru,res_company as rc " \
"where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id " \
"and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date = current_date and po.user_id = ru.id and rc.id = %s and ru.id = %s " \
"group by po.name, po.state " \
,(str(user.company_id.id),str(self.uid)))
,(str(user.company_id.id),str(self.uid)))
data = self.cr.dictfetchall()
for d in data:
@@ -65,10 +65,4 @@ class pos_sales_user_today_current_user(report_sxw.rml_parse):
report_sxw.report_sxw('report.pos.sales.user.today.current.user', 'pos.order', 'addons/point_of_sale/report/pos_sales_user_today_current_user.rml', parser=pos_sales_user_today_current_user,header='internal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -18,10 +18,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from report import report_sxw
class pos_user_product(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
@@ -33,8 +33,9 @@ class pos_user_product(report_sxw.rml_parse):
'get_total':self._get_total,
})
def _get_data(self,o):
self.total = 0.0
self.total = 0.0
data={}
sql1=""" SELECT distinct(o.id) from account_bank_statement s, account_bank_statement_line l,pos_order o,pos_order_line i where i.order_id=o.id and o.state='paid' and l.statement_id=s.id and l.pos_statement_id=o.id and s.id=%d"""%(o.id)
self.cr.execute(sql1)
@@ -51,14 +52,17 @@ class pos_user_product(report_sxw.rml_parse):
return data
def _get_user(self,object):
for o in object :
for o in object:
sql = """select ru.name from account_bank_statement as abs,res_users ru
where abs.user_id = ru.id
and abs.id = %d"""%(o.id)
self.cr.execute(sql)
data = self.cr.fetchone()
return data[0]
def _get_total(self,o):
return self.total
report_sxw.report_sxw('report.pos.user.product', 'account.bank.statement', 'addons/statement/report/pos_users_product.rml', parser=pos_user_product,header='internal')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import tools
from osv import fields,osv
@@ -39,6 +40,7 @@ class report_cash_register(osv.osv):
'balance_end_real': fields.float('Closing Balance'),
}
_order = 'date desc'
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_cash_register')
cr.execute("""
@@ -62,3 +64,5 @@ class report_cash_register(osv.osv):
to_char(s.create_date, 'YYYY-MM-DD'))""")
report_cash_register()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,95 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import tools
from osv import fields,osv
class report_pos_order(osv.osv):
_name = "report.pos.order"
_description = "Point of Sale Orders Statistics"
_auto = False
_columns = {
'date': fields.date('Date Order', readonly=True),
'year': fields.char('Year', size=4, readonly=True),
'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'),
('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'),
('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True),
'day': fields.char('Day', size=128, readonly=True),
'partner_id':fields.many2one('res.partner', 'Partner', readonly=True),
'product_id':fields.many2one('product.product', 'Product', readonly=True),
'state': fields.selection([('draft', 'Draft'), ('payment', 'Payment'),
('advance','Advance'),
('paid', 'Paid'), ('done', 'Done'), ('invoiced', 'Invoiced'), ('cancel', 'Cancel')],
'State'),
'user_id':fields.many2one('res.users', 'Salesman', readonly=True),
'price_total':fields.float('Total Price', readonly=True),
'total_discount':fields.float('Total Discount', readonly=True),
'average_price': fields.float('Average Price', readonly=True,group_operator="avg"),
'shop_id':fields.many2one('sale.shop', 'Shop', readonly=True),
'company_id':fields.many2one('res.company', 'Company', readonly=True),
'nbr':fields.integer('# of Lines', readonly=True),
'product_qty':fields.integer('# of Qty', readonly=True),
'journal_id': fields.many2one('account.journal', 'Journal'),
'delay_validation': fields.integer('Delay Validation'),
'delay_payment': fields.integer('Delay Payment'),
'date_validation': fields.date('Validation Date', required=True),
'date_payment': fields.date('Payment Date', required=True),
}
_order = 'date desc'
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_pos_order')
cr.execute("""
create or replace view report_pos_order as (
select
min(l.id) as id,
count(*) as nbr,
to_date(to_char(s.date_order, 'dd-MM-YYYY'),'dd-MM-YYYY') as date,
sum(l.qty * u.factor) as product_qty,
sum(l.qty * l.price_unit) as price_total,
sum(l.qty * l.price_ded) as total_discount,
(sum(l.qty*l.price_unit)/sum(l.qty * u.factor))::decimal(16,2) as average_price,
sum(cast(to_char(date_trunc('day',s.date_validation) - date_trunc('day',s.date_order),'DD') as int)) as delay_validation,
sum(cast(to_char(date_trunc('day',s.date_payment) - date_trunc('day',s.date_order),'DD') as int)) as delay_payment,
to_char(s.date_order, 'YYYY') as year,
to_char(s.date_order, 'MM') as month,
to_char(s.date_order, 'YYYY-MM-DD') as day,
s.partner_id as partner_id,
s.state as state,
s.user_id as user_id,
s.shop_id as shop_id,
s.company_id as company_id,
s.sale_journal as journal_id,
l.product_id as product_id,
s.date_validation,
s.date_payment
from pos_order_line as l
left join pos_order s on (s.id=l.order_id)
left join product_template pt on (pt.id=l.product_id)
left join product_uom u on (u.id=pt.uom_id)
group by
to_char(s.date_order, 'dd-MM-YYYY'),to_char(s.date_order, 'YYYY'),to_char(s.date_order, 'MM'),
to_char(s.date_order, 'YYYY-MM-DD'), s.partner_id,s.state,
s.user_id,s.shop_id,s.company_id,s.sale_journal,l.product_id,s.date_validation,
s.date_payment
having
sum(l.qty * u.factor) != 0)""")
report_pos_order()
@@ -1,106 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_report_pos_order_tree" model="ir.ui.view">
<field name="name">report.pos.order.tree</field>
<field name="model">report.pos.order</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Point of Sale Analysis">
<field name="date" invisible="1"/>
<field name="user_id" invisible="1"/>
<field name="year" invisible="1"/>
<field name="day" invisible="1"/>
<field name="month" invisible="1"/>
<field name="partner_id" invisible="1"/>
<field name="product_id" invisible="1"/>
<field name="shop_id" invisible="1"/>
<!--<field name="journal_id" invisible="1"/>-->
<field name="date_validation" invisible="1"/>
<field name="date_payment" invisible="1"/>
<field name="company_id" invisible="1" groups="base.group_multi_company"/>
<field name="nbr" sum="# of Lines"/>
<field name="product_qty" sum="# of Qty"/>
<field name="average_price" sum="Average Price"/>
<field name="total_discount" sum="Total Discount"/>
<field name="price_total" sum="Total Price"/>
<field name="delay_validation"/>
<field name="delay_payment"/>
<!--<field name="state" invisible="1"/>-->
</tree>
</field>
</record>
<record id="view_report_pos_order_search" model="ir.ui.view">
<field name="name">report.pos.order.search</field>
<field name="model">report.pos.order</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Point of Sale Analysis">
<group>
<filter icon="terp-go-year" string="Year"
domain="[('year','=',time.strftime('%%Y'))]"
help="POS ordered created during current year"/>
<filter icon="terp-go-month" string="Month"
domain="[('date','&lt;=',(datetime.date.today()+relativedelta(day=31)).strftime('%%Y-%%m-%%d')),('date','&gt;=',(datetime.date.today()-relativedelta(day=1)).strftime('%%Y-%%m-%%d'))]"
help="POS ordered created during current month"/>
<filter icon="terp-go-month"
string="Month -1"
separator="1"
domain="[('date','&lt;=', (datetime.date.today() - relativedelta(day=31, months=1)).strftime('%%Y-%%m-%%d')),('date','&gt;=',(datetime.date.today() - relativedelta(day=1,months=1)).strftime('%%Y-%%m-%%d'))]"
help="POS ordered created last month"/>
<separator orientation="vertical"/>
<filter icon="terp-go-today"
string="Today"
name="today"
separator="1"
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d'))]"
help="POS ordered created by today"/>
<separator orientation="vertical"/>
<filter icon="terp-dolar"
string="Invoiced"
domain="[('state','=',('invoiced'))]"/>
<filter icon="terp-dolar"
string="Paid"
domain="[('state','=',('paid'))]"/>
<separator orientation="vertical"/>
<field name="partner_id"/>
<field name="user_id" widget="selection">
<filter icon="terp-personal"
string="My Sales"
help="My Sales"
domain="[('user_id','=',uid)]"/>
</field>
</group>
<newline/>
<group expand="0" string="Extended Filters..." groups="base.group_extended">
<field name="date_validation"/>
<field name="date_payment"/>
</group>
<newline/>
<group expand="1" string="Group By..." colspan="10" col="12">
<filter string="Salesman" icon="terp-personal" name="User" context="{'group_by':'user_id'}"/>
<filter string="Customer" icon="terp-personal" context="{'group_by':'partner_id'}"/>
<separator orientation="vertical"/>
<filter string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/>
<separator orientation="vertical"/>
<filter string="Day" icon="terp-go-today" context="{'group_by':'day'}" help="Day of order date"/>
<filter string="Month" icon="terp-go-month" context="{'group_by':'month'}" help="Month of order date"/>
<filter string="Year" icon="terp-go-year" context="{'group_by':'year'}" help="Year of order date"/>
</group>
</search>
</field>
</record>
<record id="action_report_pos_order_all" model="ir.actions.act_window">
<field name="name">Point of Sale Analysis</field>
<field name="res_model">report.pos.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="search_view_id" ref="view_report_pos_order_search"/>
<field name="context">{'search_default_today':1,'search_default_User':1,'group_by_no_leaf':1,'group_by':[]}</field>
</record>
<menuitem action="action_report_pos_order_all" id="menu_report_pos_order_all" parent="menu_point_rep" sequence="3"/>
</data>
</openerp>