gpt4 book ai didi

python - 通过 QWeb 报告上的 fields.function 从数据库获取图像 - Odoo 8

转载 作者:行者123 更新时间:2023-12-01 04:18:27 25 4
gpt4 key购买 nike

我想打印一张图像,通过 fields.function 获取数据库中的任何图像。

我正在尝试以下操作:

def _get_image(self, cr, uid, ids, name, args, context=None):
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(partner)
return res

_columns = {
'image': fields.function(_get_image, string="Image", type="binary"),
}

但在 qweb 报告中我得到:

  File "/opt/*/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: Non-image binary fields can not be converted to HTML

如果我以表单打印图像,一切都会顺利。

如有任何帮助,我们将不胜感激,提前致谢。

最佳答案

试试这个代码:

def _get_image(self, cr, uid, ids, name, args, context=None):
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(partner)
return res

_columns = {
'image': fields.binary("Image"),
'image_x': fields.function(_get_image, string="Image", type="binary"),

}

关于python - 通过 QWeb 报告上的 fields.function 从数据库获取图像 - Odoo 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34026022/

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