[IMP] Report controller: little changes to get the barcode route working with reportlab 2.5
bzr revid: sle@openerp.com-20140224120749-nlg3n95vgghxv63y
This commit is contained in:
parent
7de120a2ef
commit
5557a1152c
|
@ -41,7 +41,7 @@ from werkzeug import exceptions
|
||||||
from werkzeug.test import Client
|
from werkzeug.test import Client
|
||||||
from werkzeug.wrappers import BaseResponse
|
from werkzeug.wrappers import BaseResponse
|
||||||
from werkzeug.datastructures import Headers
|
from werkzeug.datastructures import Headers
|
||||||
from reportlab.graphics.barcode import createBarcodeImageInMemory
|
from reportlab.graphics.barcode import createBarcodeDrawing
|
||||||
|
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
@ -462,13 +462,12 @@ class Report(http.Controller):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
width, height = int(width), int(height)
|
width, height = int(width), int(height)
|
||||||
barcode = createBarcodeImageInMemory(
|
barcode = createBarcodeDrawing(
|
||||||
type, value=value, format='png', width=width, height=height
|
type, value=value, format='png', width=width, height=height
|
||||||
)
|
)
|
||||||
|
barcode = barcode.asString('png')
|
||||||
except (ValueError, AttributeError):
|
except (ValueError, AttributeError):
|
||||||
raise exceptions.HTTPException(description='Cannot convert into barcode.')
|
raise exceptions.HTTPException(description='Cannot convert into barcode.')
|
||||||
except AssertionError:
|
|
||||||
raise exceptions.HTTPException(description='Please upgrade reportlab to at least 3.0.')
|
|
||||||
|
|
||||||
return request.make_response(barcode, headers=[('Content-Type', 'image/png')])
|
return request.make_response(barcode, headers=[('Content-Type', 'image/png')])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue