I want to do something like this in a openerp report, how would I need to go about to create this file path:
<image file="images\[[o.name]]" x="72" y="72"/>
Are there ways to create variables in rml that I could then feed to the file= attribute.
I have little to no python knowledge, but would love to get this solved.
Right now I am trying to adjust the order.rml, I can load images, but only statically ...
In the reports .py file add a python function like this:
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
in the rml itself call the function as such:
<para>[[ image_url(o['id']) and setTag('para','image') or removeParentNode('para') ]][[ image_url(o['id']) ]]</para>