gpt4 book ai didi

python - qweb 中的图像如何通过 fields.function 报告

转载 作者:太空宇宙 更新时间:2023-11-03 17:11:58 25 4
gpt4 key购买 nike

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

最佳答案

我认为你应该用 binary 字段替换你的函数字段并添加如下内容:

<span t-field="o.image_field" t-field-options="{&quot;widget&quot;: &quot;image&quot;, &quot;class&quot;: &quot;img-rounded&quot;}"/>

关于python - qweb 中的图像如何通过 fields.function 报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33980390/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com