adding images dynamically to an openerp rml report file -


i want in openerp report, how need go create file path:

<image file="images\[[o.name]]" x="72" y="72"/> 

are there ways create variables in rml feed file= attribute.

i have little no python knowledge, love solved.

right trying adjust order.rml, can load images, statically ...

in reports .py file add python function 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 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 rml call function such:

<para>[[ image_url(o['id']) , settag('para','image') or removeparentnode('para') ]][[ image_url(o['id']) ]]</para> 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -