Report 向openerp rml报告文件动态添加图像
我想在openerp报告中执行类似操作,我需要如何创建此文件路径:Report 向openerp rml报告文件动态添加图像,report,openerp,rml,Report,Openerp,Rml,我想在openerp报告中执行类似操作,我需要如何创建此文件路径: <image file="images\[[o.name]]" x="72" y="72"/> 有没有办法在rml中创建变量,然后将其馈送到file=属性 我几乎没有python知识,但我很想解决这个问题 现在我正在尝试调整order.rml,我可以加载图像,但只能静态加载…在reports.py文件中添加如下python函数: self.localcontext.update({ 'tim
<image file="images\[[o.name]]" x="72" y="72"/>
有没有办法在rml中创建变量,然后将其馈送到file=属性
我几乎没有python知识,但我很想解决这个问题
现在我正在尝试调整order.rml,我可以加载图像,但只能静态加载…在reports.py文件中添加如下python函数:
self.localcontext.update({
'time': time,
'image_url' : self._get_imagepath,
})
def _get_imagepath(self,product):
attach_ids = self.pool.get('ir.attachment').search(self.cr, self.uid, [('res_model','=','product.product'), ('res_id', '=',product)])
datas = self.pool.get('ir.attachment').read(self.cr, self.uid, attach_ids)
if len(datas):
# if there are several, pick first
try:
if datas[0]['link']:
try:
img_data = base64.encodestring(urllib.urlopen(datas[0]['link']).read())
return img_data
except Exception,innerEx:
print innerEx
elif datas[0]['datas']:
return datas[0]['datas']
except Exception,e:
print e
return None
在rml本身中,调用函数如下:
<para>[[ image_url(o['id']) and setTag('para','image') or removeParentNode('para') ]][[ image_url(o['id']) ]]</para>
在reports.py文件中添加如下python函数:
self.localcontext.update({
'time': time,
'image_url' : self._get_imagepath,
})
def _get_imagepath(self,product):
attach_ids = self.pool.get('ir.attachment').search(self.cr, self.uid, [('res_model','=','product.product'), ('res_id', '=',product)])
datas = self.pool.get('ir.attachment').read(self.cr, self.uid, attach_ids)
if len(datas):
# if there are several, pick first
try:
if datas[0]['link']:
try:
img_data = base64.encodestring(urllib.urlopen(datas[0]['link']).read())
return img_data
except Exception,innerEx:
print innerEx
elif datas[0]['datas']:
return datas[0]['datas']
except Exception,e:
print e
return None
在rml本身中,调用函数如下:
<para>[[ image_url(o['id']) and setTag('para','image') or removeParentNode('para') ]][[ image_url(o['id']) ]]</para>
你可以这么做
<image>o.company_id.logo</image>
或者以任何有意义的方式引用您的图像,即在订单上显示公司徽标,您可以在产品中添加图像字段,并根据需要在订单的行项目上显示这些图像。您可以这样做
<image>o.company_id.logo</image>
或者以任何有意义的方式引用您的图像,即在订单上显示公司徽标,您可以向产品添加图像字段,并在订单的行项目上显示这些图像字段(如果需要)。您还可以在中执行以下操作:
<header>
<pageTemplate>
<frame id="first" x1="1.3cm" y1="2.5cm" height="23.0cm" width="19cm"/>
<pageGraphics>
<image file= "/home/workspace/openERP/src/openerp-server/pixmaps/client-logo.png" x="3.3cm" y="3.5cm" height="32.0"/>
</pageGraphics>
</pageTemplate>
您还可以在中执行以下操作:
<header>
<pageTemplate>
<frame id="first" x1="1.3cm" y1="2.5cm" height="23.0cm" width="19cm"/>
<pageGraphics>
<image file= "/home/workspace/openERP/src/openerp-server/pixmaps/client-logo.png" x="3.3cm" y="3.5cm" height="32.0"/>
</pageGraphics>
</pageTemplate>
由于我不能对阿兰·贝尔的解决方案发表评论,恐怕我必须在另一个答复中纠正他 艾伦写道,你可以使用:
<image>o.company_id.logo</image>
这不完全正确,;您需要将表达式括在双方括号中,如下所示:
<image>[[ o.company_id.logo ]]</image>
对于可以传递到图像标签的属性,我将您重定向到RML文档:由于我无法对Alan Bell的解决方案发表评论,因此我必须在单独的回答中更正他 艾伦写道,你可以使用:
<image>o.company_id.logo</image>
这不完全正确,;您需要将表达式括在双方括号中,如下所示:
<image>[[ o.company_id.logo ]]</image>
对于可以传递到图像标记的属性,我将您重定向到RML文档: