From fc889e24dd649c57bd05f42fd19bfe34da86835e Mon Sep 17 00:00:00 2001 From: "Anup (OpenERP)" Date: Fri, 17 Sep 2010 17:59:36 +0530 Subject: [PATCH] [FIX/IMP] point_of_sale : YML test for report added and corrected the reports bzr revid: ach@tinyerp.com-20100917122936-n89nhvb9uor5cmo3 --- addons/point_of_sale/__openerp__.py | 3 +- addons/point_of_sale/pos_demo.xml | 9 ++ .../report/pos_payment_report_user.py | 8 +- .../point_of_sale/report/pos_users_product.py | 2 +- .../point_of_sale/test/pos_details_report.yml | 8 -- .../test/pos_payment_report_date.yml | 8 -- addons/point_of_sale/test/pos_report.yml | 97 +++++++++++++++++-- 7 files changed, 105 insertions(+), 30 deletions(-) delete mode 100644 addons/point_of_sale/test/pos_details_report.yml delete mode 100644 addons/point_of_sale/test/pos_payment_report_date.yml diff --git a/addons/point_of_sale/__openerp__.py b/addons/point_of_sale/__openerp__.py index 6f33f75f65d..ad466b12522 100644 --- a/addons/point_of_sale/__openerp__.py +++ b/addons/point_of_sale/__openerp__.py @@ -75,8 +75,7 @@ Main features : 'demo_xml': ['pos_demo.xml','singer_statement_demo.xml','multi_company_stock_data.xml',], 'test':['test/pos_test.yml', 'test/pos_report.yml', - 'test/pos_details.yml', - 'test/pos_payment_report_date.yml'], + ], 'installable': True, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/pos_demo.xml b/addons/point_of_sale/pos_demo.xml index 80ba3d24397..18029826008 100644 --- a/addons/point_of_sale/pos_demo.xml +++ b/addons/point_of_sale/pos_demo.xml @@ -61,5 +61,14 @@ Discount Applied + + St. 05/19 + 0.0 + 2010-05-19 + + + draft + + diff --git a/addons/point_of_sale/report/pos_payment_report_user.py b/addons/point_of_sale/report/pos_payment_report_user.py index 48ea148d8d1..dc829859c3e 100644 --- a/addons/point_of_sale/report/pos_payment_report_user.py +++ b/addons/point_of_sale/report/pos_payment_report_user.py @@ -40,13 +40,13 @@ class pos_payment_report_user(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 to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date = current_date " \ - "and po.user_id IN %s",(tuple(ids), ) - self.cr.execute (sql) + "and po.user_id IN %s" + self.cr.execute (sql, (tuple(ids), )) data=self.cr.dictfetchall() return data - def __pos_payment_user__total__(self,form): + def __pos_payment_user__total__(self, form): res=[] - ids = form['user_id'][0][-1] + ids = form['user_id'] 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 " \ diff --git a/addons/point_of_sale/report/pos_users_product.py b/addons/point_of_sale/report/pos_users_product.py index 3a284f1957f..141445bcafe 100644 --- a/addons/point_of_sale/report/pos_users_product.py +++ b/addons/point_of_sale/report/pos_users_product.py @@ -42,7 +42,7 @@ class pos_user_product(report_sxw.rml_parse): a_l=[] for r in data: a_l.append(r['id']) - if len(a): + if len(a_l): sql2="""SELECT sum(qty) as qty,l.price_unit*sum(l.qty) as amt,t.name as name from product_product p, product_template t, pos_order_line l where order_id IN %s and p.product_tmpl_id=t.id and l.product_id=p.id group by t.name, l.price_unit""",(tuple(a_l),) self.cr.execute(sql2) data = self.cr.dictfetchall() diff --git a/addons/point_of_sale/test/pos_details_report.yml b/addons/point_of_sale/test/pos_details_report.yml deleted file mode 100644 index 72f35b87ec5..00000000000 --- a/addons/point_of_sale/test/pos_details_report.yml +++ /dev/null @@ -1,8 +0,0 @@ -- - In order to test the PDF reports defined on a Point Of Sale, we will print a POS Details report -- - !python {model: ir.ui.menu}: | - import netsvc, tools, os, time - (data, format) = netsvc.LocalService('report.pos.details').create(cr, uid, [], {'model':'ir.ui.menu', 'form':{'date_start': time.strftime('%Y-%m-%d'), 'date_end': time.strftime('%Y-%m-%d') }}, {}) - if tools.config['test_report_directory']: - file(os.path.join(tools.config['test_report_directory'], 'point_of_sale- pos details report'+format), 'wb+').write(data) \ No newline at end of file diff --git a/addons/point_of_sale/test/pos_payment_report_date.yml b/addons/point_of_sale/test/pos_payment_report_date.yml deleted file mode 100644 index 15eefcdc6ab..00000000000 --- a/addons/point_of_sale/test/pos_payment_report_date.yml +++ /dev/null @@ -1,8 +0,0 @@ -- - In order to test the PDF reports defined on a Point Of Sale, we will print a POS Sales Lines report -- - !python {model: ir.ui.menu}: | - import netsvc, tools, os, time - (data, format) = netsvc.LocalService('report.pos.payment.report.date').create(cr, uid, [1], {'model':'ir.ui.menu', 'form':{'date_start': time.strftime('%Y-%m-%d'), 'date_end': time.strftime('%Y-%m-%d'), 'user_id': [ref('base.user_root')] }}, {}) - if tools.config['test_report_directory']: - file(os.path.join(tools.config['test_report_directory'], 'point_of_sale- pos sales lines report'+format), 'wb+').write(data) \ No newline at end of file diff --git a/addons/point_of_sale/test/pos_report.yml b/addons/point_of_sale/test/pos_report.yml index bd89ca2015d..1747fb60305 100644 --- a/addons/point_of_sale/test/pos_report.yml +++ b/addons/point_of_sale/test/pos_report.yml @@ -1,5 +1,5 @@ - - In order to test the PDF reports defined on a Point Of Sale, we will print a POS Detail Summary report + In order to test the PDF reports defined on a Point Of Sale, we will print a POS Detail Summary Report - !python {model: pos.order}: | import netsvc, tools, os @@ -8,7 +8,7 @@ file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-details_summary report'+format), 'wb+').write(data) - - In order to test the PDF reports defined on a Point Of Sale, we will print a POS Invoice report + 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 netsvc, tools, os @@ -17,7 +17,7 @@ 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 + 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 netsvc, tools, os @@ -26,7 +26,7 @@ file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-lines report'+format), 'wb+').write(data) - - In order to test the PDF reports defined on a Point of Sale, we will print a POS Receipt report + In order to test the PDF reports defined on a Point of Sale, we will print a POS Receipt Report - !python {model: pos.order}: | import netsvc, tools, os @@ -35,7 +35,7 @@ file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-receipt report'+format), 'wb+').write(data) - - In order to test the PDF reports defined on a Point of Sale, we will print a POS Receipt With Reimbursement report + In order to test the PDF reports defined on a Point of Sale, we will print a POS Receipt With Reimbursement Report - !python {model: pos.order}: | import netsvc, tools, os @@ -44,10 +44,93 @@ file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-receipt with reimbursement report'+format), 'wb+').write(data) - - In order to test the PDF reports defined on a point of sale, we will print a POS Receipt Without Reimbursement report + In order to test the PDF reports defined on a point of sale, we will print a POS Receipt Without Reimbursement Report - !python {model: pos.order}: | import netsvc, tools, os (data, format) = netsvc.LocalService('report.pos.receipt.without.remboursment').create(cr, uid, [ref('point_of_sale.order_pos1'), ref('point_of_sale.order_pos2')], {}, {}) if tools.config['test_report_directory']: - file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-receipt without reimbursement report'+format), 'wb+').write(data) \ No newline at end of file + file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-receipt without reimbursement report'+format), 'wb+').write(data) +- + In order to test the PDF reports defined on a Point Of Sale, we will print a POS Payment Report Report +- + !python {model: ir.ui.menu}: | + import netsvc, tools, os, time + (data, format) = netsvc.LocalService('report.pos.payment.report.date').create(cr, uid, [1], {'model':'ir.ui.menu', 'form':{'date_start': time.strftime('%Y-%m-%d'), 'date_end': time.strftime('%Y-%m-%d'), 'user_id': [ref('base.user_root')] }}, {}) + if tools.config['test_report_directory']: + file(os.path.join(tools.config['test_report_directory'], 'point_of_sale- pos sales lines report'+format), 'wb+').write(data) +- + In order to test the PDF reports defined on a Point Of Sale, we will print a POS Details Report +- + !python {model: ir.ui.menu}: | + import netsvc, tools, os, time + (data, format) = netsvc.LocalService('report.pos.details').create(cr, uid, [], {'model':'ir.ui.menu', 'form':{'date_start': time.strftime('%Y-%m-%d'), 'date_end': time.strftime('%Y-%m-%d') }}, {}) + if tools.config['test_report_directory']: + file(os.path.join(tools.config['test_report_directory'], 'point_of_sale- pos details report'+format), 'wb+').write(data) +- + In order to test the PDF reports defined on a Point Of Sale, we will print a Account Statement Report +- + !python {model: account.bank.statement}: | + import netsvc, tools, os, time + (data, format) = netsvc.LocalService('report.account.statement').create(cr, uid, [ref('point_of_sale.account_bank_statement_st0')], {}, {}) + if tools.config['test_report_directory']: + file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-account_statement_report'+format), 'wb+').write(data) +- + In order to test the PDF reports defined on a Point Of Sale, we will print a POS User Product Report +- + !python {model: account.bank.statement}: | + import netsvc, tools, os, time + (data, format) = netsvc.LocalService('report.pos.user.product').create(cr, uid, [ref('point_of_sale.account_bank_statement_st0')], {}, {}) + if tools.config['test_report_directory']: + file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-user_product_report'+format), 'wb+').write(data) +- + In order to test the PDF reports defined on a Point Of Sale, we will print a POS All Close Cashbox Of the Day Report +- + !python {model: account.bank.statement}: | + import netsvc, tools, os, time + (data, format) = netsvc.LocalService('report.all.closed.cashbox.of.the.day').create(cr, uid, [ref('point_of_sale.account_bank_statement_st0')], {}, {}) + if tools.config['test_report_directory']: + file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-all_closed_cash_box_of_the_day_report'+format), 'wb+').write(data) +- + In order to test the PDF reports defined on a Point of Sale, we will print a POS Sales User Report +- + !python {model: pos.order}: | + import netsvc, tools, os, time + data_dict = {'model':'ir.ui.menu', 'form':{'date_start': time.strftime('%Y-%m-%d'), 'date_end': time.strftime('%Y-%m-%d'),'user_id':[ref('base.user_root')] }} + (data, format) = netsvc.LocalService('report.pos.sales.user').create(cr, uid, [ref('point_of_sale.order_pos1'), ref('point_of_sale.order_pos2')], data_dict, {}) + if tools.config['test_report_directory']: + file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-sales_user_report'+format), 'wb+').write(data) +- + In order to test the PDF reports defined on a Point of Sale, we will print a POS Sales User Today Report +- + !python {model: pos.order}: | + import netsvc, tools, os, time + data_dict = {'model':'ir.ui.menu', 'form':{'user_id':[ref('base.user_root')] }} + (data, format) = netsvc.LocalService('report.pos.sales.user.today').create(cr, uid, [ref('point_of_sale.order_pos1'), ref('point_of_sale.order_pos2')], data_dict, {}) + if tools.config['test_report_directory']: + file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-sales_user_today_report'+format), 'wb+').write(data) +- + 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 netsvc, tools, os, time + (data, format) = netsvc.LocalService('report.pos.payment.report').create(cr, uid, [ref('point_of_sale.order_pos1'), ref('point_of_sale.order_pos2')], {}, {}) + if tools.config['test_report_directory']: + file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-payment_report'+format), 'wb+').write(data) +- + In order to test the PDF reports defined on a Point of Sale, we will print a POS Payment User Report +- + !python {model: pos.order}: | + import netsvc, tools, os, time + data_dict = {'model':'ir.ui.menu', 'form':{'user_id':[ref('base.user_root'),ref('base.user_demo')] }} + (data, format) = netsvc.LocalService('report.pos.payment.report.user').create(cr, uid, [ref('point_of_sale.order_pos1'), ref('point_of_sale.order_pos2')], data_dict, {}) + if tools.config['test_report_directory']: + file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-payment_user_report'+format), 'wb+').write(data) +- + In order to test the PDF reports defined on a Point of Sale, we will print a POS Today's Sales of Current User Report +- + !python {model: pos.order}: | + import netsvc, tools, os, time + (data, format) = netsvc.LocalService('report.pos.sales.user.today.current.user').create(cr, uid, [ref('point_of_sale.order_pos1'), ref('point_of_sale.order_pos2')], {}, {}) + if tools.config['test_report_directory']: + file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-sales_today_current_user_report'+format), 'wb+').write(data) \ No newline at end of file