From 67fc7252c5a43645076551c1b95a3447acf6d6c2 Mon Sep 17 00:00:00 2001 From: openerp-sle Date: Mon, 17 Feb 2014 15:05:23 +0100 Subject: [PATCH] [IMP] Lunch order report converted to QWeb bzr revid: openerp-sle@openerp-sle.home-20140217140523-591vtpvc5yd6nuuv --- addons/lunch/__openerp__.py | 2 +- addons/lunch/lunch_report.xml | 10 +- addons/lunch/report/order.py | 25 +-- addons/lunch/report/order.rml | 184 ----------------------- addons/lunch/views/report_lunchorder.xml | 79 ++++++++++ 5 files changed, 100 insertions(+), 200 deletions(-) delete mode 100644 addons/lunch/report/order.rml create mode 100644 addons/lunch/views/report_lunchorder.xml diff --git a/addons/lunch/__openerp__.py b/addons/lunch/__openerp__.py index 46c07c211c6..f8a4a1ddcf2 100644 --- a/addons/lunch/__openerp__.py +++ b/addons/lunch/__openerp__.py @@ -42,7 +42,7 @@ If you want to save your employees' time and avoid them to always have coins in """, 'data': ['security/lunch_security.xml','lunch_view.xml','wizard/lunch_order_view.xml','wizard/lunch_validation_view.xml','wizard/lunch_cancel_view.xml','lunch_report.xml', 'report/report_lunch_order_view.xml', - 'security/ir.model.access.csv',], + 'security/ir.model.access.csv','views/report_lunchorder.xml'], 'css':['static/src/css/lunch.css'], 'images': ['images/new_order.jpeg','images/lunch_account.jpeg','images/order_by_supplier_analysis.jpeg','images/alert.jpeg'], 'demo': ['lunch_demo.xml',], diff --git a/addons/lunch/lunch_report.xml b/addons/lunch/lunch_report.xml index 942caadeed3..990694af4a9 100644 --- a/addons/lunch/lunch_report.xml +++ b/addons/lunch/lunch_report.xml @@ -2,12 +2,12 @@ + report_type="qweb-pdf" + name="lunch.report_lunchorder" + file="lunch.report_lunchorder" + /> diff --git a/addons/lunch/report/order.py b/addons/lunch/report/order.py index 064fe8bc719..0bb99f01017 100644 --- a/addons/lunch/report/order.py +++ b/addons/lunch/report/order.py @@ -20,11 +20,11 @@ ############################################################################## import time -from openerp.report import report_sxw -from openerp.osv import osv +from openerp.addons.web import http +from openerp.addons.web.http import request -class order(report_sxw.rml_parse): +class order(http.Controller): def get_lines(self, user,objects): lines=[] @@ -60,19 +60,24 @@ class order(report_sxw.rml_parse): notes.append(obj.note) return notes - def __init__(self, cr, uid, name, context): - super(order, self).__init__(cr, uid, name, context) + @http.route(['/report/lunch.report_lunchorder/'], type='http', auth='user', website=True, multilang=True) + def report_lunch(self, docids): + self.cr, self.uid, self.context = request.cr, request.uid, request.context + + ids = [int(i) for i in docids.split(',')] + report_obj = request.registry['lunch.order.line'] + docs = report_obj.browse(self.cr, self.uid, ids, context=self.context) + self.net_total=0.0 - self.localcontext.update({ + docargs = { + 'docs': docs, 'time': time, 'get_lines': self.get_lines, 'get_users': self.get_users, 'get_total': self.get_total, 'get_nettotal': self.get_nettotal, 'get_note': self.get_note, - }) + } + return request.registry['report'].render(self.cr, self.uid, [], 'lunch.report_lunchorder', docargs) -report_sxw.report_sxw('report.lunch.order.line', 'lunch.order.line', - 'addons/lunch/report/order.rml',parser=order, header='external') # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/lunch/report/order.rml b/addons/lunch/report/order.rml deleted file mode 100644 index 1ab52a88bda..00000000000 --- a/addons/lunch/report/order.rml +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name/Date - - - Order - - - Description - - - Unit Price - - - - - - - - - - - - - - - - [[ user.name ]] - [[ user.login ]] - [[ user.email ]] - - - - Lunch Order - - - - Name/Date - - - Order - - - Description - - - Unit Price - - - -
- [[repeatIn(get_users(objects),'o')]] - - - - [[ o.name ]] - - - - - - - - [[ formatLang(get_total(o,objects)) ]] [[ (o.company_id and o.company_id.currency_id and o.company_id.currency_id.symbol) or '' ]] - - - -
- [[ repeatIn(get_lines(o,objects),'lines') ]] - - - - [[ formatLang(lines.date,date='True') ]] - - - [[ (lines.product_id and lines.product_id.name) or '' ]] - - - [[ lines.note]] - - - [[ lines.price ]] [[ (o.company_id and o.company_id.currency_id and o.company_id.currency_id.symbol) or '' ]] - - - -
-
- - - - - - - - - Total : - - - [[ formatLang(get_nettotal()) ]] [[ (o.company_id and o.company_id.currency_id and o.company_id.currency_id.symbol) or '' ]] - - - - - - -
-
-
diff --git a/addons/lunch/views/report_lunchorder.xml b/addons/lunch/views/report_lunchorder.xml new file mode 100644 index 00000000000..d67ce98a7df --- /dev/null +++ b/addons/lunch/views/report_lunchorder.xml @@ -0,0 +1,79 @@ + + + + + +