openerp报告似乎缓存了图像数据

发布于 2024-11-06 00:59:30 字数 1814 浏览 4 评论 0原文

我的销售订单模板中有以下 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 中,对于给定索引,所有图像都是相同的。

有什么想法吗?

I've the following rml in my sale order template:

<section>
 [[ repeatIn(o.order_line, 'l') ]]
<blockTable colWidths="250.0,92.0,21.0,80.0,85.0" style="Táblá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>

(There are many such image tags with different indexes. I've just stripped the code.)

then my report generator defines

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

all this seems to work fine, the print statement shows different results, but not the final pdf!

in the pdf all the images are the same for a given index.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流云如水 2024-11-13 00:59:30

我也有同样的问题。

我将: 替换

<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不是我的专长,但通过一些调试这应该能够工作)

I had the same problem.

I replaced:

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

with:

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

and my problem was solved.

Translated to your problem it should be something like:

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

(this probably contains a lot of bugs, rml isn't my specialty, but with some debugging this should be able to work)

蘑菇王子 2024-11-13 00:59:30

这被认为是 openerp 中的错误并且已经修复。

This was recognised as a bug in openerp and is already fixed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文