1

openerpレポートでこのようなことをしたいのですが、このファイルパスを作成するにはどうすればよいでしょうか。

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

rmlで変数を作成し、それをfile=属性にフィードする方法はありますか。

私はPythonの知識がほとんどないかまったくありませんが、これを解決したいと思っています。

現在、order.rmlを調整しようとしています。画像を読み込むことはできますが、静的にしかできません...

4

4 に答える 4

7

レポートの .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>
于 2011-02-25T16:36:56.573 に答える
1

また、次のこともできます

<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> 

于 2012-04-19T05:25:27.050 に答える