콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
12137 화면

I need to overlap an image with text in my report. "Normal" html code like that does not work - the image is not shown at all:

 <template id="external_layout_header">
<div class="header">
<table width="22cm" border="1" height="30cm">
<tr background="logo.jpg">
<div><span t-field="company.partner_id"/></div>
<div><span t-field="company.zip"/> <span t-field="company.city"/></div>
</tr>
</table>
</div>
</template>

It seems to me, that qweb is unable to load images from disk. Even if I provide absolute path for the image, it is not shown neither in html nor in pdf. I get the following error:


2015-07-20 21:39:56,306 12436 ERROR TEST_DB openerp.addons.website.models.ir_http: 500 Internal Server Error:

Traceback (most recent call last):

File "/opt/odoo/odoo8/addons/website/models/ir_http.py", line 199, in _handle_exception

response = super(ir_http, self)._handle_exception(exception)

File "/opt/odoo/odoo8/openerp/addons/base/ir/ir_http.py", line 147, in _handle_exception

return request._handle_exception(exception)

File "/opt/odoo/odoo8/openerp/http.py", line 666, in _handle_exception

return super(HttpRequest, self)._handle_exception(exception)

File "/opt/odoo/odoo8/openerp/addons/base/ir/ir_http.py", line 173, in _dispatch

result = request.dispatch()

File "/opt/odoo/odoo8/openerp/http.py", line 684, in dispatch

r = self._call_function(**self.params)

File "/opt/odoo/odoo8/openerp/http.py", line 310, in _call_function

return checked_call(self.db, *args, **kwargs)

File "/opt/odoo/odoo8/openerp/service/model.py", line 113, in wrapper

return f(dbname, *args, **kwargs)

File "/opt/odoo/odoo8/openerp/http.py", line 307, in checked_call

return self.endpoint(*a, **kw)

File "/opt/odoo/odoo8/openerp/http.py", line 803, in __call__

return self.method(*args, **kw)

File "/opt/odoo/odoo8/openerp/http.py", line 403, in response_wrap

response = f(*args, **kw)

File "/opt/odoo/odoo8/addons/report/controllers/main.py", line 49, in report_routes

docids = [int(i) for i in docids.split(',')]

ValueError: invalid literal for int() with base 10: 'logo.jpg'

Why does it look for an integer when reading name/path for the image? Is this a known bug? Can somebody confirm that Odoo v8 / qweb is unable to load resource files from disk?


아바타
취소
베스트 답변

If you want to show an image from the database you can just use the image widget like this:

<span t-field="o.image_field_name" t-field-options='{"widget": "image"}'/>

And if you want to show an image stored as a file:

<img t-att-src="'/module_name/static/src/img/image_name.png'" />

Note: respect the order and the type of the quotes

아바타
취소
관련 게시물 답글 화면 활동
1
6월 21
7956
2
8월 20
4081
0
6월 25
539
1
3월 24
3531
2
10월 22
6260