我试图通过fields.function在wqeb报告中显示图像。 在表单内部一切顺利,但是当在qweb中尝试报告时发生此错误, 我仍然不明白这个错误的含义。 任何帮助将不胜感激,提前谢谢。
File "/opt/ikom/openerp/addons/base/ir/ir_qweb.py", line 791, in value_to_html
raise ValueError("Non-image binary fields can not be converted to HTML")
ValueError:非图像二进制字段无法转换为HTML
我试图通过这种方式获得
'chart': fields.function(_get_image, string="Grafica de pallets", type="binary"),
def _get_image(self, cr, uid, ids, name, args, context=None):
pdb.set_trace()
res = dict.fromkeys(ids)
for record_browse in self.browse(cr, uid, ids):
partner = self.pool.get('res.partner').browse(cr,uid,6,context=None).image
res[record_browse.id] = base64.encodestring(chart_encoded)
return res
<span itemprop="image" t-field="o.chart" t-field-options='{"widget": "image", "alt-field": "name"}'/>
答案 0 :(得分:1)
我认为你应该用binary
字段替换你的函数字段并添加如下内容:
<span t-field="o.image_field" t-field-options="{"widget": "image", "class": "img-rounded"}"/>