QR 码未出现在报告中。为什么?
A QR-code doesn't appear in the report. Why?
我尝试打印一个简单的二维码图像,但无法打印。我使用了 code that I found in the documentation 但它没有用。我还需要什么吗?我安装了 reportlabs
库。
<img t-att-src="'/report/barcode/QR/%s' % 'My text in qr code'" />
<img t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s'%('QR', 'text', 200, 200)"/>
我检查了日志文件,发现了这个错误:
2015-07-13 12:01:09,305 28260 INFO wiretec_01 werkzeug: 127.0.0.1 - - [13/Jul/2015 12:01:09] "GET /report/barcode/QR/My%20text%20in%20qr%20code HTTP/1.1" 500 -
2015-07-13 12:01:09,322 28260 ERROR wiretec_01 werkzeug: Error on request:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/opt/odoo8/openerp/service/server.py", line 281, in app
return self.app(e, s)
File "/opt/odoo8/openerp/service/wsgi_server.py", line 216, in application
return application_unproxied(environ, start_response)
File "/opt/odoo8/openerp/service/wsgi_server.py", line 202, in application_unproxied
result = handler(environ, start_response)
File "/opt/odoo8/openerp/http.py", line 1280, in __call__
return self.dispatch(environ, start_response)
File "/opt/odoo8/openerp/http.py", line 1254, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo8/openerp/http.py", line 1421, in dispatch
result = ir_http._dispatch()
File "/opt/odoo8/openerp/addons/base/ir/ir_http.py", line 130, in _dispatch
return self._handle_exception(e)
File "/opt/odoo8/openerp/addons/base/ir/ir_http.py", line 100, in _handle_exception
return request._handle_exception(exception)
File "/opt/odoo8/openerp/http.py", line 659, in _handle_exception
return super(HttpRequest, self)._handle_exception(exception)
File "/opt/odoo8/openerp/addons/base/ir/ir_http.py", line 126, in _dispatch
result = request.dispatch()
File "/opt/odoo8/openerp/http.py", line 677, in dispatch
r = self._call_function(**self.params)
File "/opt/odoo8/openerp/http.py", line 303, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo8/openerp/service/model.py", line 113, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo8/openerp/http.py", line 300, in checked_call
return self.endpoint(*a, **kw)
File "/opt/odoo8/openerp/http.py", line 796, in __call__
return self.method(*args, **kw)
File "/opt/odoo8/openerp/http.py", line 396, in response_wrap
response = f(*args, **kw)
File "/opt/odoo8/modules/addons/report/controllers/main.py", line 94, in report_barcode
barcode = barcode.asString('png')
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/shapes.py", line 830, in asString
rl_config.showBoundary),**_extraKW(self,'_renderPM_',**kw))
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py", line 660, in drawToString
drawToFile(d,s,fmt=fmt, dpi=dpi, bg=bg, configPIL=configPIL)
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py", line 655, in drawToFile
c = drawToPMCanvas(d, dpi=dpi, bg=bg, configPIL=configPIL, showBoundary=showBoundary)
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py", line 641, in drawToPMCanvas
draw(d, c, 0, 0, showBoundary=showBoundary)
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py", line 50, in draw
R.draw(renderScaledDrawing(drawing), canvas, x, y, showBoundary=showBoundary)
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderbase.py", line 198, in draw
self.initState(x,y) #this is the push()
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py", line 99, in initState
self.applyState()
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py", line 93, in applyState
self._canvas.setFont(s['fontName'], s['fontSize'])
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py", line 374, in setFont
_setFont(self._gs,fontName,fontSize)
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py", line 227, in _setFont
raise RenderPMError("Can't setFont(%s) missing the T1 files?\nOriginally %s: %s" % (fontName,s1,s2))
RenderPMError: Can't setFont(Times-Roman) missing the T1 files?
Originally <type 'exceptions.TypeError'>: makeT1Font() argument 2 must be string, not None
我也安装了软件包 ttf-mscorefonts-installer
嗯,我在Odoo论坛找到了解决方法,here:
在 /path/to/your/python/site-packages/reportlab/fonts
这些文件中下载并解压缩
http://www.reportlab.com/ftp/fonts/pfbfer.zip
重启服务器试试
我尝试打印一个简单的二维码图像,但无法打印。我使用了 code that I found in the documentation 但它没有用。我还需要什么吗?我安装了 reportlabs
库。
<img t-att-src="'/report/barcode/QR/%s' % 'My text in qr code'" />
<img t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s'%('QR', 'text', 200, 200)"/>
我检查了日志文件,发现了这个错误:
2015-07-13 12:01:09,305 28260 INFO wiretec_01 werkzeug: 127.0.0.1 - - [13/Jul/2015 12:01:09] "GET /report/barcode/QR/My%20text%20in%20qr%20code HTTP/1.1" 500 -
2015-07-13 12:01:09,322 28260 ERROR wiretec_01 werkzeug: Error on request:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/opt/odoo8/openerp/service/server.py", line 281, in app
return self.app(e, s)
File "/opt/odoo8/openerp/service/wsgi_server.py", line 216, in application
return application_unproxied(environ, start_response)
File "/opt/odoo8/openerp/service/wsgi_server.py", line 202, in application_unproxied
result = handler(environ, start_response)
File "/opt/odoo8/openerp/http.py", line 1280, in __call__
return self.dispatch(environ, start_response)
File "/opt/odoo8/openerp/http.py", line 1254, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo8/openerp/http.py", line 1421, in dispatch
result = ir_http._dispatch()
File "/opt/odoo8/openerp/addons/base/ir/ir_http.py", line 130, in _dispatch
return self._handle_exception(e)
File "/opt/odoo8/openerp/addons/base/ir/ir_http.py", line 100, in _handle_exception
return request._handle_exception(exception)
File "/opt/odoo8/openerp/http.py", line 659, in _handle_exception
return super(HttpRequest, self)._handle_exception(exception)
File "/opt/odoo8/openerp/addons/base/ir/ir_http.py", line 126, in _dispatch
result = request.dispatch()
File "/opt/odoo8/openerp/http.py", line 677, in dispatch
r = self._call_function(**self.params)
File "/opt/odoo8/openerp/http.py", line 303, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo8/openerp/service/model.py", line 113, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo8/openerp/http.py", line 300, in checked_call
return self.endpoint(*a, **kw)
File "/opt/odoo8/openerp/http.py", line 796, in __call__
return self.method(*args, **kw)
File "/opt/odoo8/openerp/http.py", line 396, in response_wrap
response = f(*args, **kw)
File "/opt/odoo8/modules/addons/report/controllers/main.py", line 94, in report_barcode
barcode = barcode.asString('png')
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/shapes.py", line 830, in asString
rl_config.showBoundary),**_extraKW(self,'_renderPM_',**kw))
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py", line 660, in drawToString
drawToFile(d,s,fmt=fmt, dpi=dpi, bg=bg, configPIL=configPIL)
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py", line 655, in drawToFile
c = drawToPMCanvas(d, dpi=dpi, bg=bg, configPIL=configPIL, showBoundary=showBoundary)
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py", line 641, in drawToPMCanvas
draw(d, c, 0, 0, showBoundary=showBoundary)
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py", line 50, in draw
R.draw(renderScaledDrawing(drawing), canvas, x, y, showBoundary=showBoundary)
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderbase.py", line 198, in draw
self.initState(x,y) #this is the push()
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py", line 99, in initState
self.applyState()
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py", line 93, in applyState
self._canvas.setFont(s['fontName'], s['fontSize'])
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py", line 374, in setFont
_setFont(self._gs,fontName,fontSize)
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py", line 227, in _setFont
raise RenderPMError("Can't setFont(%s) missing the T1 files?\nOriginally %s: %s" % (fontName,s1,s2))
RenderPMError: Can't setFont(Times-Roman) missing the T1 files?
Originally <type 'exceptions.TypeError'>: makeT1Font() argument 2 must be string, not None
我也安装了软件包 ttf-mscorefonts-installer
嗯,我在Odoo论坛找到了解决方法,here:
在 /path/to/your/python/site-packages/reportlab/fonts
这些文件中下载并解压缩
http://www.reportlab.com/ftp/fonts/pfbfer.zip
重启服务器试试