This question has been flagged
2 Replies
10476 Views

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?


Avatar
Discard
Best Answer

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

Avatar
Discard
Author Best Answer

Has nobody really never loaded an image file from disk within a qweb report to explain to me how it works?

Avatar
Discard