我试图通过 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"}'/>