【问题标题】:openerp report seems to cache image dataopenerp 报告似乎缓存了图像数据
【发布时间】:2011-05-10 12:30:59
【问题描述】:

我的销售订单模板中有以下 rml:

<section>
 [[ repeatIn(o.order_line, 'l') ]]
<blockTable colWidths="250.0,92.0,21.0,80.0,85.0" style="T&#xE1;bl&#xE1;zat2">
  <tr>
    <td>
      <para style="P13">[[ l.name ]]</para>
    </td>
    <td>
      <para style="terp_default_Right_9">[[ formatLang(l.product_uos and l.product_uos_qty or l.product_uom_qty, digits=0) ]] </para>
    </td>
    <td>
      <para style="P13">[[ l.product_uos and l.product_uos.name or l.product_uom.name ]]</para>
    </td>
    <td>
      <para style="P9">[[ formatLang(l.price_unit, digits=0 ) ]] [[ o.pricelist_id.currency_id.name ]]</para>
    </td>
    <td>
      <para style="P9">[[ formatLang(l.price_subtotal, digits=0) ]] [[ o.pricelist_id.currency_id.name ]]</para>
    </td>
  </tr>
</blockTable>

<para style="P15">
  [[ l.product_id.description_sale ]]
</para>

<image height="260" width="520">[[ o.state=='draft' and get_product_attachment(1, l.product_id) or removeParentNode('image')]]</image>

</section>

(这样的图片标签有很多,索引不同,我只是剥离了代码。)

然后我的报告生成器定义

def get_product_attachment(self, index, product):
    context = {}
    attach = self.pool.get('ir.attachment').search(self.cr, self.uid, [('res_id','=',product.id), ('name','ilike', 'pict%d' % index)])
    attach = attach and self.pool.get('ir.attachment').browse(self.cr, self.uid, attach[0]) or False
    if attach:
        print 'a', product.id, index, attach, attach.datas[:30]
        return attach.datas
    else:
        return False

这一切似乎工作正常,打印语句显示不同的结果,但不是最终的 pdf!

在 pdf 中,对于给定索引,所有图像都是相同的。

有什么想法吗?

【问题讨论】:

标签: reportlab openerp rml


【解决方案1】:

我遇到了同样的问题。

我换了:

<image width='6cm' height='6cm'>[[ item['image'] ]]</image>

与:

<para>[[ item['image'] and setTag('para','image',{'width':'6cm','height':'6cm'}) ]][[ item['image'] ]]</para>

我的问题解决了。

翻译成你的问题应该是这样的:

<para>[[ o.state=='draft' and get_product_attachment(1, l.product_id) and  setTag('para','image',{'width':'260','height':'510'})]][[get_product_attachment(1, l.product_id)]]</image>

(这可能包含很多错误,rml不是我的专长,但通过一些调试应该可以工作)

【讨论】:

    【解决方案2】:

    这被识别为a bug in openerp 并且已经修复。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-02
      • 1970-01-01
      • 1970-01-01
      • 2016-04-25
      • 1970-01-01
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多