[IMP] point_of_sale: remove some reports

- report.transaction.pos
- report.sales.by.user.pos
- report.sales.by.user.pos.month
These reports where not called anywhere and have been replaced by pivot views

Remove order reports that can be easily replaced by use of the pivot view of
report.pos.order
Add a session_id field and a filter on report.pos.order to make it equivalent.
The invoice report is only useful when called from the pos UI so keeping the
report but not added in the print menu
This commit is contained in:
Martin Trigaux
2016-02-17 17:09:59 +01:00
parent 62406fa4bf
commit e741de8b0c
19 changed files with 28 additions and 1250 deletions
-6
View File
@@ -34,7 +34,6 @@ Main Features
'security/ir.model.access.csv',
'data/default_barcode_patterns.xml',
'wizard/pos_box.xml',
'wizard/pos_details.xml',
'wizard/pos_discount.xml',
'wizard/pos_open_statement.xml',
'wizard/pos_payment.xml',
@@ -59,10 +58,6 @@ Main Features
'views/res_config_view.xml',
'views/report_statement.xml',
'views/report_usersproduct.xml',
'views/report_saleslines.xml',
'views/report_detailsofsales.xml',
'views/report_payment.xml',
'views/report_sessionsummary.xml',
'views/report_userlabel.xml',
'views/point_of_sale.xml',
'views/point_of_sale_dashboard.xml',
@@ -76,7 +71,6 @@ Main Features
'test/00_register_open.yml',
'test/01_order_to_payment.yml',
'test/02_order_to_invoice.yml',
'test/point_of_sale_report.yml',
'test/account_statement_reports.yml',
],
'installable': True,
+2 -6
View File
@@ -1,12 +1,8 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import pos_users_product
import account_statement
import pos_receipt
import pos_invoice
import pos_lines
import pos_details
import pos_payment_report
import pos_report
import pos_order_report
import pos_receipt
import pos_users_product
-181
View File
@@ -1,181 +0,0 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import time
from openerp.osv import osv
from openerp.report import report_sxw
class pos_details(report_sxw.rml_parse):
def _get_invoice(self, inv_id):
res={}
if inv_id:
self.cr.execute("select number from account_invoice as ac where id = %s", (inv_id,))
res = self.cr.fetchone()
return res[0] or 'Draft'
else:
return ''
def _get_all_users(self):
user_obj = self.pool.get('res.users')
return user_obj.search(self.cr, self.uid, [])
def _pos_sales_details(self, form):
pos_obj = self.pool.get('pos.order')
user_obj = self.pool.get('res.users')
data = []
result = {}
user_ids = form['user_ids'] or self._get_all_users()
company_id = user_obj.browse(self.cr, self.uid, self.uid).company_id.id
pos_ids = pos_obj.search(self.cr, self.uid, [('date_order','>=',form['date_start'] + ' 00:00:00'),('date_order','<=',form['date_end'] + ' 23:59:59'),('user_id','in',user_ids),('state','in',['done','paid','invoiced']),('company_id','=',company_id)])
for pos in pos_obj.browse(self.cr, self.uid, pos_ids, context=self.localcontext):
for pol in pos.lines:
result = {
'code': pol.product_id.default_code,
'name': pol.product_id.name,
'invoice_id': pos.invoice_id.id,
'price_unit': pol.price_unit,
'qty': pol.qty,
'discount': pol.discount,
'total': (pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0)),
'date_order': pos.date_order,
'pos_name': pos.name,
'uom': pol.product_id.uom_id.name
}
data.append(result)
self.total += result['total']
self.qty += result['qty']
self.discount += result['discount']
if data:
return data
else:
return {}
def _get_qty_total_2(self):
return self.qty
def _get_sales_total_2(self):
return self.total
def _get_sum_invoice_2(self, form):
pos_obj = self.pool.get('pos.order')
user_obj = self.pool.get('res.users')
user_ids = form['user_ids'] or self._get_all_users()
company_id = user_obj.browse(self.cr, self.uid, self.uid).company_id.id
pos_ids = pos_obj.search(self.cr, self.uid, [('date_order','>=',form['date_start'] + ' 00:00:00'),('date_order','<=',form['date_end'] + ' 23:59:59'),('user_id','in',user_ids),('company_id','=',company_id),('invoice_id','<>',False)])
for pos in pos_obj.browse(self.cr, self.uid, pos_ids):
for pol in pos.lines:
self.total_invoiced += (pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))
return self.total_invoiced or False
def _paid_total_2(self):
return self.total or 0.0
def _get_sum_dis_2(self):
return self.discount or 0.0
def _get_sum_discount(self, form):
#code for the sum of discount value
pos_obj = self.pool.get('pos.order')
user_obj = self.pool.get('res.users')
user_ids = form['user_ids'] or self._get_all_users()
company_id = user_obj.browse(self.cr, self.uid, self.uid).company_id.id
pos_ids = pos_obj.search(self.cr, self.uid, [('date_order','>=',form['date_start'] + ' 00:00:00'),('date_order','<=',form['date_end'] + ' 23:59:59'),('user_id','in',user_ids),('company_id','=',company_id)])
for pos in pos_obj.browse(self.cr, self.uid, pos_ids):
for pol in pos.lines:
self.total_discount += ((pol.price_unit * pol.qty) * (pol.discount / 100))
return self.total_discount or False
def _get_payments(self, form):
statement_line_obj = self.pool.get("account.bank.statement.line")
pos_order_obj = self.pool.get("pos.order")
user_ids = form['user_ids'] or self._get_all_users()
company_id = self.pool['res.users'].browse(self.cr, self.uid, self.uid).company_id.id
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','in',user_ids), ('company_id', '=', company_id)])
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:
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 " \
"group by aj.name ",(tuple(a_l),))
data = self.cr.dictfetchall()
return data
else:
return {}
def _total_of_the_day(self, objects):
return self.total or 0.00
def _sum_invoice(self, objects):
return reduce(lambda acc, obj:
acc + obj.invoice_id.amount_total,
[o for o in objects if o.invoice_id and o.invoice_id.number],
0.0)
def _ellipsis(self, orig_str, maxlen=100, ellipsis='...'):
maxlen = maxlen - len(ellipsis)
if maxlen <= 0:
maxlen = 1
new_str = orig_str[:maxlen]
return new_str
def _strip_name(self, name, maxlen=50):
return self._ellipsis(name, maxlen, ' ...')
def _get_tax_amount(self, form):
taxes = {}
account_tax_obj = self.pool.get('account.tax')
user_ids = form['user_ids'] or self._get_all_users()
pos_order_obj = self.pool.get('pos.order')
company_id = self.pool['res.users'].browse(self.cr, self.uid, self.uid).company_id.id
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','in',user_ids), ('company_id', '=', company_id)])
for order in pos_order_obj.browse(self.cr, self.uid, pos_ids):
currency = order.session_id.currency_id
for line in order.lines:
if line.product_id.taxes_id:
line_taxes = line.product_id.taxes_id.compute_all(line.price_unit * (1-(line.discount or 0.0)/100.0), currency, line.qty, product=line.product_id, partner=line.order_id.partner_id or False)
for tax in line_taxes['taxes']:
taxes.setdefault(tax['id'], {'name': tax['name'], 'amount':0.0})
taxes[tax['id']]['amount'] += tax['amount']
return taxes.values()
def _get_user_names(self, user_ids):
user_obj = self.pool.get('res.users')
return ', '.join(map(lambda x: x.name, user_obj.browse(self.cr, self.uid, user_ids)))
def __init__(self, cr, uid, name, context):
super(pos_details, self).__init__(cr, uid, name, context=context)
self.total = 0.0
self.qty = 0.0
self.total_invoiced = 0.0
self.discount = 0.0
self.total_discount = 0.0
self.localcontext.update({
'time': time,
'strip_name': self._strip_name,
'getpayments': self._get_payments,
'getsumdisc': self._get_sum_discount,
'gettotaloftheday': self._total_of_the_day,
'gettaxamount': self._get_tax_amount,
'pos_sales_details':self._pos_sales_details,
'getqtytotal2': self._get_qty_total_2,
'getsalestotal2': self._get_sales_total_2,
'getsuminvoice2':self._get_sum_invoice_2,
'getpaidtotal2': self._paid_total_2,
'getinvoice':self._get_invoice,
'get_user_names': self._get_user_names,
})
class report_pos_details(osv.AbstractModel):
_name = 'report.point_of_sale.report_detailsofsales'
_inherit = 'report.abstract_report'
_template = 'point_of_sale.report_detailsofsales'
_wrapped_report_class = pos_details
-43
View File
@@ -1,43 +0,0 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import time
from openerp.osv import osv
from openerp.report import report_sxw
class pos_lines(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(pos_lines, self).__init__(cr, uid, name, context=context)
self.total = 0.0
self.localcontext.update({
'time': time,
'total_quantity': self.__total_quantity__,
'taxes':self.__taxes__,
})
def __total_quantity__(self, obj):
tot = 0
for line in obj.lines:
tot += line.qty
self.total = tot
return self.total
def __taxes__(self, obj):
self.cr.execute ( " Select acct.name from pos_order as po " \
" LEFT JOIN pos_order_line as pol ON po.id = pol.order_id " \
" LEFT JOIN product_product as pp ON pol.product_id = pp.id"
" LEFT JOIN product_taxes_rel as ptr ON pp.product_tmpl_id = ptr.prod_id " \
" LEFT JOIN account_tax as acct ON acct.id = ptr.tax_id " \
" WHERE pol.id = %s", (obj.id,))
res=self.cr.fetchone()[0]
return res
class report_pos_lines(osv.AbstractModel):
_name = 'report.point_of_sale.report_saleslines'
_inherit = 'report.abstract_report'
_template = 'point_of_sale.report_saleslines'
_wrapped_report_class = pos_lines
@@ -33,6 +33,7 @@ class pos_order_report(osv.osv):
'pos_categ_id': fields.many2one('pos.category','Public Category', readonly=True),
'stock_location_id': fields.many2one('stock.location', 'Warehouse', readonly=True),
'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', readonly=True),
'session_id;: fields.many2one('pos.session', string='Session', readonly=True),
}
_order = 'date desc'
@@ -63,6 +64,7 @@ class pos_order_report(osv.osv):
pt.pos_categ_id,
pc.stock_location_id,
s.pricelist_id,
s.session_id,
s.invoice_id IS NOT NULL AS invoiced
from pos_order_line as l
left join pos_order s on (s.id=l.order_id)
@@ -73,6 +75,14 @@ class pos_order_report(osv.osv):
left join pos_config pc on (ps.config_id=pc.id)
group by
s.date_order, s.partner_id,s.state, pt.categ_id,
s.user_id,s.location_id,s.company_id,s.sale_journal,s.pricelist_id,s.invoice_id,l.product_id,s.create_date,pt.categ_id,pt.pos_categ_id,p.product_tmpl_id,ps.config_id,pc.stock_location_id
having
sum(l.qty * u.factor) != 0)""")
s.user_id, s.location_id, s.company_id, s.sale_journal,
s.pricelist_id, s.invoice_id, s.create_date, s.session_id,
l.product_id,
pt.categ_id, pt.pos_categ_id,
p.product_tmpl_id,
ps.config_id,
pc.stock_location_id
HAVING
SUM(l.qty * u.factor) != 0
)
""")
@@ -1,52 +0,0 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import time
from openerp.osv import osv
from openerp.report import report_sxw
class pos_payment_report(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(pos_payment_report, self).__init__(cr, uid, name, context=context)
self.total = 0.0
self.localcontext.update({
'time': time,
'pos_payment': self._pos_payment,
'pos_payment_total':self._pos_payment_total,
})
def _pos_payment(self, obj):
self.total = 0
data={}
sql = """ select id from pos_order where id = %d"""%(obj.id)
self.cr.execute(sql)
if self.cr.fetchone():
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 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:
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 to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date = current_date")
data=self.cr.dictfetchall()
for d in data:
self.total += d['price_unit'] * d['qty']
return data
def _pos_payment_total(self, o):
return self.total
class report_pos_payment(osv.AbstractModel):
_name = 'report.point_of_sale.report_payment'
_inherit = 'report.abstract_report'
_template = 'point_of_sale.report_payment'
_wrapped_report_class = pos_payment_report
-121
View File
@@ -1,121 +0,0 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp.osv import fields, osv
from openerp 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((100.0-line.discount) * line.price_unit * line.qty / 100.0) 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,
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
)
""")
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
)
""")
@@ -1,13 +1,10 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_pos_order,pos.order,model_pos_order,group_pos_user,1,1,1,1
access_pos_order_line,pos.order.line,model_pos_order_line,group_pos_user,1,1,1,1
access_report_transaction_pos,report.transaction.pos,model_report_transaction_pos,group_pos_manager,1,1,1,1
access_stock_picking_pos_user,stock.picking pos_user,stock.model_stock_picking,group_pos_user,1,1,1,1
access_stock_warehouse_pos_user,stock.warehouse pos_user,stock.model_stock_warehouse,group_pos_user,1,0,0,0
access_pos_order_stock_worker,pos.order stock_worker,model_pos_order,stock.group_stock_user,1,0,0,0
access_stock_move_pos_user,stock.move pos_user,stock.model_stock_move,group_pos_user,1,1,1,1
access_report_sales_by_user_pos,report.sales.by.user.pos,model_report_sales_by_user_pos,group_pos_user,1,0,0,0
access_report_sales_by_user_pos_month,report.sales.by.user.pos.month,model_report_sales_by_user_pos_month,group_pos_user,1,0,0,0
access_report_pos_order,report.pos.order,model_report_pos_order,group_pos_user,1,1,1,1
access_account_journal_pos_user,account.journal pos_user,account.model_account_journal,group_pos_user,1,0,0,0
access_account_payment_method_pos_user,account.payment.method pos_user,account.model_account_payment_method,group_pos_manager,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_pos_order pos.order model_pos_order group_pos_user 1 1 1 1
3 access_pos_order_line pos.order.line model_pos_order_line group_pos_user 1 1 1 1
access_report_transaction_pos report.transaction.pos model_report_transaction_pos group_pos_manager 1 1 1 1
4 access_stock_picking_pos_user stock.picking pos_user stock.model_stock_picking group_pos_user 1 1 1 1
5 access_stock_warehouse_pos_user stock.warehouse pos_user stock.model_stock_warehouse group_pos_user 1 0 0 0
6 access_pos_order_stock_worker pos.order stock_worker model_pos_order stock.group_stock_user 1 0 0 0
7 access_stock_move_pos_user stock.move pos_user stock.model_stock_move group_pos_user 1 1 1 1
access_report_sales_by_user_pos report.sales.by.user.pos model_report_sales_by_user_pos group_pos_user 1 0 0 0
access_report_sales_by_user_pos_month report.sales.by.user.pos.month model_report_sales_by_user_pos_month group_pos_user 1 0 0 0
8 access_report_pos_order report.pos.order model_report_pos_order group_pos_user 1 1 1 1
9 access_account_journal_pos_user account.journal pos_user account.model_account_journal group_pos_user 1 0 0 0
10 access_account_payment_method_pos_user account.payment.method pos_user account.model_account_payment_method group_pos_manager 1 0 0 0
@@ -1,43 +0,0 @@
-
In order to test the PDF reports defined on a Point Of Sale, we will print a POS Invoice Report
-
!python {model: pos.order}: |
import os
import openerp.report
from openerp import tools
data, format = openerp.report.render_report(cr, uid, [ref('pos_order_pos1')], 'point_of_sale.report_invoice', {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-invoice_report.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on a Point Of Sale, we will print a POS Lines Report
-
!python {model: pos.order}: |
import os
import openerp.report
from openerp import tools
data, format = openerp.report.render_report(cr, uid, [ref('pos_order_pos1')], 'point_of_sale.report_saleslines', {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-lines_report.'+format), 'wb+').write(data)
-
Print the POS Details Report through the wizard
-
!python {model: ir.ui.menu}: |
import time
ctx={}
ctx.update({'model': 'ir.ui.menu','active_ids': []})
data_dict = {'date_start': time.strftime('%Y-%m-%d'), 'date_end': time.strftime('%Y-%m-%d'), 'user_ids': [(6,0,[ref('base.user_root')])]}
from openerp.tools import test_reports
test_reports.try_report_action(cr, uid, 'action_report_pos_details',wiz_data=data_dict, context=ctx, our_module='point_of_sale')
-
In order to test the PDF reports defined on a Point of Sale, we will print a POS Payment Report
-
!python {model: pos.order}: |
import os, time
import openerp.report
from openerp import tools
data, format = openerp.report.render_report(cr, uid, [ref('pos_order_pos0')], 'point_of_sale.report_payment', {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-payment_report.'+format), 'wb+').write(data)
@@ -10,269 +10,15 @@
file="point_of_sale.report_userlabel"
/>
<report
id="pos_invoice_report"
string="Invoice"
model="pos.order"
report_type="qweb-pdf"
name="point_of_sale.report_invoice"
file="point_of_sale.report_invoice"
/>
<report
id="pos_lines_report"
string="Sales Lines"
model="pos.order"
report_type="qweb-pdf"
name="point_of_sale.report_saleslines"
file="point_of_sale.report_saleslines"
auto="False"
/>
<report
id="pos_lines_detail"
string="Details of Sales"
model="pos.order"
report_type="qweb-pdf"
name="point_of_sale.report_detailsofsales"
file="point_of_sale.report_detailsofsales"
menu="False"
/>
<report
id="pos_payment_report"
string="Today's Payment"
model="pos.order"
report_type="qweb-pdf"
name="point_of_sale.report_payment"
file="point_of_sale.report_payment"
/>
<report
id="action_report_pos_session_summary"
string="Session Summary"
model="pos.session"
report_type="qweb-pdf"
name="point_of_sale.report_sessionsummary"
file="point_of_sale.report_sessionsummary"
/>
<!-- report -->
<record model="ir.ui.view" id="view_pos_trans_user_form">
<field name="name">report.trans.pos.user.form</field>
<field name="model">report.transaction.pos</field>
<field name="arch" type="xml">
<form string="POS ">
<group col="4">
<field name="user_id"/>
<field name="journal_id"/>
<field name="jl_id"/>
<field name="date_create" widget="date"/>
<field name="no_trans"/>
<field name="amount"/>
<field name="invoice_id"/>
</group>
</form>
</field>
<!-- used from POS UI, no need to be in print menu -->
<record id="pos_invoice_report" model="ir.actions.report.xml">
<field name="name">Invoice</field>
<field name="model">pos.order</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">point_of_sale.report_invoice</field>
</record>
<record model="ir.ui.view" id="view_trans_pos_user_tree">
<field name="name">Sales by user</field>
<field name="model">report.transaction.pos</field>
<field name="arch" type="xml">
<tree string="POS">
<field name="date_create" widget="date" />
<field name="user_id"/>
<field name="journal_id"/>
<field name="jl_id"/>
<field name="no_trans" sum="Total Transaction"/>
<field name="amount" sum="Amount total"/>
<field name="product_nb" />
<field name="invoice_id"/>
<field name="disc"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_report_transaction_pos_calendar">
<field name="name">report.transaction.pos.calendar</field>
<field name="model">report.transaction.pos</field>
<field eval="2" name="priority"/>
<field name="arch" type="xml">
<calendar color="user_id" date_start="date_create" string="POS Report">
<field name="journal_id"/>
<field name="amount"/>
</calendar>
</field>
</record>
<record model="ir.ui.view" id="view_report_transaction_pos_graph">
<field name="name">report.transaction.pos.graph</field>
<field name="model">report.transaction.pos</field>
<field eval="2" name="priority"/>
<field name="arch" type="xml">
<graph type="bar" string="POS Report">
<field name="user_id" />
<field name="amount"/>
<field group="True" name="journal_id"/>
</graph>
</field>
</record>
<record model="ir.actions.act_window" id="action_trans_pos_tree_today">
<field name="name">Sales by day</field>
<field name="res_model">report.transaction.pos</field>
<field name="view_type">form</field>
<field name="view_mode">tree,calendar,form,graph</field>
<field name="domain">[('date_create','=',time.strftime('%Y-%m-%d'))]</field>
</record>
<record model="ir.actions.act_window" id="action_trans_pos_tree_month">
<field name="name">Sales by month</field>
<field name="res_model">report.transaction.pos</field>
<field name="view_type">form</field>
<field name="view_mode">tree,calendar,form,graph</field>
<field name="domain">[('date_create','like',time.strftime('%Y-%m'))]</field>
</record>
<record model="ir.actions.act_window" id="action_trans_pos_tree">
<field name="name">Sales by user</field>
<field name="res_model">report.transaction.pos</field>
<field name="view_type">form</field>
<field name="view_mode">tree,calendar,form,graph</field>
<field name="view_id" ref="view_trans_pos_user_tree"/>
</record>
<record model="ir.ui.view" id="view_report_sales_by_user_pos_form">
<field name="name">report.sales.by.user.pos.form</field>
<field name="model">report.sales.by.user.pos</field>
<field name="arch" type="xml">
<form string="POS ">
<group col="4">
<field name="date_order" widget="date"/>
<field name="qty"/>
<field name="amount"/>
<field name="user_id"/>
</group>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_report_sales_by_user_pos_tree">
<field name="name">report.sales.by.user.pos.tree</field>
<field name="model">report.sales.by.user.pos</field>
<field name="arch" type="xml">
<tree string="POS">
<field name="date_order" widget="date"/>
<field name="qty"/>
<field name="amount"/>
<field name="user_id"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_report_sales_by_user_pos_calendar">
<field name="name">report.sales.by.user.pos.calendar</field>
<field name="model">report.sales.by.user.pos</field>
<field eval="2" name="priority"/>
<field name="arch" type="xml">
<calendar color="user_id" date_start="date_order" string="POS Report">
<field name="qty"/>
<field name="amount" />
</calendar>
</field>
</record>
<record model="ir.ui.view" id="view_report_sales_by_user_pos_graph">
<field name="name">report.sales.by.user.pos.graph</field>
<field name="model">report.sales.by.user.pos</field>
<field eval="2" name="priority"/>
<field name="arch" type="xml">
<graph type="bar" string="Sales by User">
<field name="user_id" />
<field name="amount"/>
</graph>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_sales_by_user_pos_today">
<field name="name">Sales by User</field>
<field name="res_model">report.sales.by.user.pos</field>
<field name="view_type">form</field>
<field name="view_mode">tree,calendar,form,graph</field>
<field name="domain">[('date_order','=',time.strftime('%Y-%m-%d'))]</field>
</record>
<!-- Sales of user by month -->
<record model="ir.ui.view" id="view_report_sales_by_user_pos_month_form">
<field name="name">report.sales.by.user.pos.month.form</field>
<field name="model">report.sales.by.user.pos.month</field>
<field name="arch" type="xml">
<form string="POS ">
<group col="4">
<field name="date_order" widget="date"/>
<field name="qty"/>
<field name="amount"/>
<field name="user_id"/>
</group>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_report_sales_by_user_pos_month_tree">
<field name="name">report.sales.by.user.pos.month.tree</field>
<field name="model">report.sales.by.user.pos.month</field>
<field name="arch" type="xml">
<tree string="POS">
<field name="date_order" widget="date"/>
<field name="qty"/>
<field name="amount"/>
<field name="user_id"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_report_sales_by_user_pos_month_calendar">
<field name="name">report.sales.by.user.pos.month.calendar</field>
<field name="model">report.sales.by.user.pos.month</field>
<field eval="2" name="priority"/>
<field name="arch" type="xml">
<calendar color="user_id" date_start="date_order" string="POS Report">
<field name="qty"/>
<field name="amount" />
</calendar>
</field>
</record>
<record model="ir.ui.view" id="view_report_sales_by_user_pos_month_graph">
<field name="name">report.sales.by.user.pos.month.graph</field>
<field name="model">report.sales.by.user.pos.month</field>
<field eval="2" name="priority"/>
<field name="arch" type="xml">
<graph type="bar" string="Sales by User">
<field name="user_id" />
<field name="amount"/>
</graph>
</field>
</record>
<record model="ir.actions.act_window" id="action_report_sales_by_user_pos_month">
<field name="name">Sales by User Monthly</field>
<field name="res_model">report.sales.by.user.pos.month</field>
<field name="view_type">form</field>
<field name="view_mode">tree,calendar,form,graph</field>
<field name="domain">[('date_order','like',time.strftime('%Y-%m'))]</field>
</record>
</data>
</openerp>
@@ -53,6 +53,13 @@
</field>
</record>
<record id="filter_orders_per_session" model="ir.filters">
<field name="name">Per session</field>
<field name="model_id">report.pos.order</field>
<field name="user_id" eval="False"/>
<field name="context">{'group_by': ['date', 'session_id'], 'measures': ['price_total']}</field>
</record>
<record id="action_report_pos_order_all" model="ir.actions.act_window">
<field name="name">Orders Analysis</field>
<field name="res_model">report.pos.order</field>
@@ -242,9 +242,6 @@
<field name="view_id" ref="view_pos_order_tree_all_sales_lines" />
</record>
<menuitem action="action_report_pos_details"
id="menu_pos_details" parent="menu_point_rep" sequence="6" />
<record id="view_pos_order_filter" model="ir.ui.view">
<field name="name">pos.order.list.select</field>
<field name="model">pos.order</field>
@@ -1,140 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_detailsofsales">
<t t-call="report.html_container">
<t t-call="report.internal_layout">
<div class="page">
<h2>Details of Sales</h2>
<div class="row mt32">
<div class="col-xs-3">
<strong>Company</strong>:<br/>
<span t-esc="res_company.name"/>
</div>
<div class="col-xs-3">
<strong>Users</strong>:<br/>
<span t-esc="get_user_names(data['form']['user_ids']) or 'All'"/>
</div>
<div class="col-xs-3">
<strong>Print Date</strong>:<br/>
<span t-esc="formatLang(time.strftime('%Y-%m-%d'),date=True)"/>
</div>
</div>
<div class="row mb32">
<div class="col-xs-3">
<strong>Start Period</strong>:<br/>
<span t-esc="formatLang(data['form']['date_start'],date=True)"/>
</div>
<div class="col-xs-3">
<strong>End Period</strong>:<br/>
<span t-esc="formatLang(data['form']['date_end'],date=True)"/>
</div>
</div>
<table class="table table-condensed">
<thead>
<th><strong>Date</strong></th>
<th><strong>Order</strong></th>
<th><strong>Product</strong></th>
<th class="text-right"><strong>Price</strong></th>
<th class="text-center"><strong>Qty</strong></th>
<th class="text-center"><strong>Disc(%)</strong></th>
<th class="text-center"><strong>Invoiced</strong></th>
</thead>
<tbody>
<tr t-foreach="pos_sales_details(data['form'])" t-as="line_ids">
<td>
<span t-esc="formatLang(line_ids['date_order'], date_time=True)"/>
</td>
<td>
<span t-esc="line_ids['pos_name']"/>
</td>
<td>
[<t t-if="line_ids['code']">
<span t-esc="line_ids['code']"/>
</t>]
<span t-esc="line_ids['name']"/>
</td>
<td class="text-right">
<span t-esc="formatLang(line_ids['price_unit'], dp='Sale Price', currency_obj=res_company.currency_id)"/>
</td>
<td class="text-center">
<span t-esc="formatLang(line_ids['qty'])"/>
<span t-esc="line_ids['uom']"/>
</td>
<td class="text-center">
<span t-esc="formatLang(line_ids['discount'], dp='Sale Price')"/>
</td>
<td class="text-center">
<t t-if="line_ids['invoice_id']">
<span t-esc="getinvoice(line_ids['invoice_id'])"/>
</t>
</td>
</tr>
</tbody>
</table>
<table class="table table-condensed">
<tr t-if="gettaxamount(data['form'])"><td colspan="2"><strong>Taxes</strong></td></tr>
<tr t-foreach="gettaxamount(data['form'])" t-as="tax">
<td><span t-esc="tax['name']"/></td>
<td class="text-right">
<strong t-esc="formatLang(tax['amount'], currency_obj = res_company.currency_id)"/>
</td>
</tr>
<tr>
<td colspan="2"><strong>Payment</strong></td>
</tr>
<tr t-foreach="getpayments(data['form'])" t-as="payment">
<td><span t-esc="payment['name']"/></td>
<td class="text-right">
<strong t-esc="formatLang(payment['sum'], dp='Account', currency_obj=res_company.currency_id)"/>
</td>
</tr>
<tr>
<td colspan="2"><strong>Summary</strong></td>
</tr>
<tr>
<td><strong>Sales total(Revenue)</strong></td>
<td class="text-right">
<strong t-esc="formatLang(getsalestotal2(), dp='Sale Price', currency_obj=res_company.currency_id)"/>
</td>
</tr>
<tr>
<td><strong>Qty of product</strong></td>
<td class="text-right">
<strong t-esc="formatLang(getqtytotal2())"/>
</td>
</tr>
<tr>
<td><strong>Total invoiced</strong></td>
<td class="text-right">
<strong t-esc="formatLang(getsuminvoice2(data['form']), dp='Sale Price', currency_obj=res_company.currency_id)"/>
</td>
</tr>
<tr>
<td><strong>Total discount</strong></td>
<td class="text-right">
<strong t-esc="formatLang(getsumdisc(data['form']), dp='Sale Price', currency_obj=res_company.currency_id)"/>
</td>
</tr>
<tr>
<td><strong>Total paid</strong></td>
<td class="text-right">
<strong t-esc="formatLang(getpaidtotal2(), dp='Sale Price', currency_obj=res_company.currency_id)"/>
</td>
</tr>
<tr>
<td><strong>Total of the day</strong></td>
<td class="text-right">
<strong t-esc="formatLang(gettotaloftheday(data['form']), dp='Sale Price', currency_obj = res_company.currency_id)"/>
</td>
</tr>
</table>
</div>
</t>
</t>
</template>
</data>
</openerp>
@@ -1,91 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_payment">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="report.internal_layout">
<div class="page">
<h2>Today's Payments</h2>
<div class="row mt32 mb32">
<div class="col-xs-3">
<strong>Company</strong>:
<br/>
<span t-field="res_company.name"/>
</div>
<div class="col-xs-3">
<strong>Print date</strong>:
<br/>
<t t-esc="formatLang(time.strftime('%Y-%m-%d'), date='True')"/>
</div>
</div>
<t t-set="pos_payment" t-value="pos_payment(o)"/>
<table class="table table-condensed" t-if="pos_payment">
<thead>
<tr>
<td>
<strong>Product</strong>
</td>
<td class="text-center">
<strong>Qty</strong>
</td>
<td class="text-center">
<strong>Disc.(%)</strong>
</td>
<td class="text-right">
<strong>Unit Price</strong>
</td>
<td class="text-right">
<strong>Total</strong>
</td>
</tr>
</thead>
<tbody>
<tr t-foreach="pos_payment" t-as="line_ids">
<td>
<t t-if="line_ids['code']">
<span t-esc="line_ids['code']"/>
</t>
<t t-if="line_ids['name']">
<span t-esc="line_ids['name']"/>
</t>
</td>
<td class="text-right">
<span t-esc="formatLang(line_ids['qty'])"/>
<t t-if="line_ids['uom']">
<span t-esc="line_ids['uom']"/>
</t>
</td>
<td class="text-right">
<span t-esc="formatLang(line_ids['discount'])"/>
</td>
<td class="text-right">
<span t-esc="formatLang(line_ids['price_unit'])"/>
</td>
<td class="text-right">
<span t-esc="formatLang(line_ids['total'], currency_obj=res_company.currency_id)"/>
</td>
</tr>
</tbody>
</table>
<div class="row" t-if="pos_payment_total(o)">
<div class="col-xs-4 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<td>
<strong>Net Total</strong>
</td>
<td class="text-right">
<span t-esc="formatLang(pos_payment_total(o), currency_obj=res_company.currency_id)"/>
</td>
</tr>
</table>
</div>
</div>
</div>
</t>
</t>
</t>
</template>
</data>
</openerp>
@@ -1,98 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_saleslines">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="report.internal_layout">
<div class="page">
<h2>POS Lines</h2>
<div class="row mt32 mb32">
<div class="col-xs-3">
<strong>Company</strong>:<br/>
<span t-field="res_company.name"/>
</div>
<div class="col-xs-3">
<strong>Print date</strong>:<br/>
<t t-esc="formatLang(time.strftime('%Y-%m-%d'), date=True)"/>
</div>
<div class="col-xs-3">
<strong>No. Of Articles</strong>:<br/>
<t t-esc="total_quantity(o)"/>
</div>
</div>
<table class="table table-condensed">
<thead>
<tr>
<th><strong>Description</strong></th>
<th><strong>Tax</strong></th>
<th class="text-right"><strong>Quantity</strong></th>
<th class="text-right"><strong>Unit Price</strong></th>
<th class="text-right" groups="sale.group_discount_per_so_line"><strong>Disc. (%)</strong></th>
<th class="text-right"><strong>Price</strong></th>
</tr>
</thead>
<tbody>
<tr t-foreach="o.lines" t-as="l">
<td>
<t t-if="l.product_id and l.product_id.code">
[<span t-field="l.product_id.code"/>]
</t>
<span t-field="l.product_id.name"/>
</td>
<td>
<t t-esc="taxes(l)"/>
</td>
<td class="text-right">
<span t-field="l.qty"/>
<span t-field="l.product_id.uom_id.name" groups="product.group_uom"/>
</td>
<td class="text-right">
<span t-field="l.price_unit"/>
</td>
<td class="text-right" groups="sale.group_discount_per_so_line">
<span t-field="l.discount"/>
</td>
<td class="text-right">
<span t-field="l.price_subtotal" t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
</td>
</tr>
</tbody>
</table>
<div class="row">
<div class="col-xs-4 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<td><strong>Total Without Taxes</strong></td>
<td class="text-right">
<span t-esc="o.amount_total - o.amount_tax"
t-esc-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr>
<td>Taxes</td>
<td class="text-right">
<span t-field="o.amount_tax"
t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr class="border-black">
<td><strong>Total</strong></td>
<td class="text-right">
<span t-field="o.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
</td>
</tr>
</table>
</div>
</div>
</div>
</t>
</t>
</t>
</template>
</data>
</openerp>
@@ -1,124 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_sessionsummary">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="report.internal_layout">
<div class="page">
<h2>Session Summary: <span t-field="o.name"/></h2>
<div class="row mt32 mb32">
<div class="col-xs-3">
<strong>Responsible</strong>:<br/>
<span t-field="o.user_id"/>
</div>
<div class="col-xs-3">
<strong>Point of Sale</strong>:<br/>
<span t-field="o.config_id"/>
</div>
<div class="col-xs-3">
<strong>Opening Date</strong>:<br/>
<span t-field="o.start_at"/>
</div>
<div class="col-xs-3">
<strong>Closing Date</strong>:<br/>
<span t-field="o.stop_at"/>
</div>
</div>
<h4>Statement Summary</h4>
<table class="table table-condensed mb32">
<thead>
<tr>
<th>
<strong>Reference</strong>
</th>
<th>
<strong>Journal</strong>
</th>
<th class="text-right">
<strong>Starting Balance</strong>
</th>
<th class="text-right">
<strong>Total Transactions</strong>
</th>
<th class="text-right">
<strong>Ending Balance</strong>
</th>
<th class="text-right">
<strong>Difference</strong>
</th>
<th class="text-right" groups="base.group_multi_currency">
<strong>Currency</strong>
</th>
<th class="text-right">
<strong>Status</strong>
</th>
</tr>
</thead>
<tbody>
<tr t-foreach="o.statement_ids" t-as="statement">
<td><span t-field="statement.name"/></td>
<td><span t-field="statement.journal_id"/></td>
<td class="text-right">
<span t-field="statement.balance_start"
t-field-options='{"widget": "monetary", "display_currency": "statement.currency_id"}'/>
</td>
<td class="text-right">
<span t-field="statement.total_entry_encoding"
t-field-options='{"widget": "monetary", "display_currency": "statement.currency_id"}'/>
</td>
<td class="text-right">
<span t-field="statement.balance_end_real"
t-field-options='{"widget": "monetary", "display_currency": "statement.currency_id"}'/>
</td>
<td class="text-right">
<span t-field="statement.difference"
t-field-options='{"widget": "monetary", "display_currency": "statement.currency_id"}'/>
</td>
<td class="text-right" groups="base.group_multi_currency">
<span t-field="statement.currency_id"/>
</td>
<td class="text-right"><span t-field="statement.state"/></td>
</tr>
</tbody>
</table>
<t t-foreach="o.statement_ids" t-as="statement">
<h4 t-if="statement.line_ids">Statement Details: <span t-esc="statement.name"/></h4>
<table class="table table-condensed" t-if="statement.line_ids">
<thead>
<tr>
<th>Date</th>
<th>Description</th>
<th>Reference</th>
<th>Partner</th>
<th>Account</th>
<th class="text-right">Amount</th>
</tr>
</thead>
<tbody>
<tr t-foreach="statement.line_ids" t-as="line">
<td><span t-field="line.date"/></td>
<td><span t-field="line.name"/></td>
<td><span t-field="line.ref"/></td>
<td><span t-field="line.partner_id"/></td>
<td><span t-field="line.account_id"/></td>
<td class="text-right">
<span t-field="line.amount"
t-field-options='{"widget": "monetary", "display_currency": "statement.currency_id"}'/>
</td>
</tr>
</tbody>
</table>
</t>
</div>
</t>
</t>
</t>
</template>
</data>
</openerp>
-1
View File
@@ -2,7 +2,6 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import pos_box
import pos_details
import pos_discount
import pos_open_statement
import pos_payment
@@ -1,39 +0,0 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import time
from openerp.osv import osv, fields
class pos_details(osv.osv_memory):
_name = 'pos.details'
_description = 'Sales Details'
_columns = {
'date_start': fields.date('Date Start', required=True),
'date_end': fields.date('Date End', required=True),
'user_ids': fields.many2many('res.users', 'pos_details_report_user_rel', 'user_id', 'wizard_id', 'Salespeople'),
}
_defaults = {
'date_start': fields.date.context_today,
'date_end': fields.date.context_today,
}
def print_report(self, cr, uid, ids, context=None):
"""
To get the date and print the report
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return : retrun report
"""
if context is None:
context = {}
datas = {'ids': context.get('active_ids', [])}
res = self.read(cr, uid, ids, ['date_start', 'date_end', 'user_ids'], context=context)
res = res and res[0] or {}
datas['form'] = res
if res.get('id',False):
datas['ids']=[res['id']]
return self.pool['report'].get_action(cr, uid, [], 'point_of_sale.report_detailsofsales', data=datas, context=context)
@@ -1,36 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- pos.details -->
<record id="view_pos_details" model="ir.ui.view">
<field name="name">POS Details</field>
<field name="model">pos.details</field>
<field name="arch" type="xml">
<form string="POS Details">
<group col="4" string="Dates">
<field name="date_start"/>
<field name="date_end"/>
</group>
<field name="user_ids"/>
<footer>
<button name="print_report" type="object" string="Print Report" class="btn-primary"/>
<button string="Cancel" class="btn-default" special="cancel"/>
</footer>
</form>
</field>
</record>
<record id="action_report_pos_details" model="ir.actions.act_window">
<field name="name">Sale Details</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">pos.details</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>