qweb中的图像如何按字段报告.函数



im试图通过fields.function在wqeb报告中显示图像。在表单中,一切都很顺利,但当qweb中的try报告trow出现此错误时,我仍然不明白这个错误的含义。如有任何帮助,我们将不胜感激,提前表示感谢。

  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;}"/>

最新更新