diff options
Diffstat (limited to 'addons/report/controllers/main.py')
| -rw-r--r-- | addons/report/controllers/main.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/addons/report/controllers/main.py b/addons/report/controllers/main.py index 5f6df9996bf..56236990316 100644 --- a/addons/report/controllers/main.py +++ b/addons/report/controllers/main.py @@ -22,6 +22,7 @@ from openerp.addons.web.http import Controller, route, request from openerp.addons.web.controllers.main import _serialize_exception from openerp.osv import osv +from openerp.tools import html_escape import simplejson from werkzeug import exceptions, url_decode @@ -71,7 +72,7 @@ class ReportController(Controller): # Misc. route utils #------------------------------------------------------ @route(['/report/barcode', '/report/barcode/<type>/<path:value>'], type='http', auth="user") - def report_barcode(self, type, value, width=600, height=100): + def report_barcode(self, type, value, width=600, height=100, humanreadable=0): """Contoller able to render barcode images thanks to reportlab. Samples: <img t-att-src="'/report/barcode/QR/%s' % o.name"/> @@ -81,11 +82,14 @@ class ReportController(Controller): :param type: Accepted types: 'Codabar', 'Code11', 'Code128', 'EAN13', 'EAN8', 'Extended39', 'Extended93', 'FIM', 'I2of5', 'MSI', 'POSTNET', 'QR', 'Standard39', 'Standard93', 'UPCA', 'USPS_4State' + :param humanreadable: Accepted values: 0 (default) or 1. 1 will insert the readable value + at the bottom of the output image """ try: - width, height = int(width), int(height) + width, height, humanreadable = int(width), int(height), bool(humanreadable) barcode = createBarcodeDrawing( - type, value=value, format='png', width=width, height=height + type, value=value, format='png', width=width, height=height, + humanReadable = humanreadable ) barcode = barcode.asString('png') except (ValueError, AttributeError): @@ -130,14 +134,14 @@ class ReportController(Controller): return response else: return - except osv.except_osv, e: + except Exception, e: se = _serialize_exception(e) error = { 'code': 200, 'message': "Odoo Server Error", 'data': se } - return request.make_response(simplejson.dumps(error)) + return request.make_response(html_escape(simplejson.dumps(error))) @route(['/report/check_wkhtmltopdf'], type='json', auth="user") def check_wkhtmltopdf(self): |
