3
votes

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

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

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

2 Answers

0
votes

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)

0
votes

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