Skip to Content
Menu
This question has been flagged
4 Replies
4851 Views

Hello guys,

    We are able to display the picture of a product template in a PDF report.

    We are able to display the picture of a product variant in a PDF report.

    But the width of the image of a product variant is uncontrollable in the PDF.

    In the html version of the report, it is easy to control the width withs html or css.

    But html and css doesn't work for product variant image in the PDF report. 

    But what is the trick to control the width of the picture of the product variant??? 

Look here, this cap is the picture of a product variant :




UPDATE #1

Here is our code to display the variant (product.product) image in the PDF.

 

<td>

<span t-if="order_line.product_id.image_variant">

<span t-field="order_line.product_id.image_variant" t-field-options="{&quot;widget&quot;: &quot;image&quot;, &quot;class&quot;: &quot;img-rounded&quot;}" />

</span>

</td>



But the width is still uncontrollable.


UPDATE #2

May be I should store image_small in database for each product variant (in product.product)???


UPDATE #3
I have tried this code :

<img t-if="l.product_id.image_variant" t-att-src="'data:image/png;base64,%s' % l.product_id.image_variant" class="img-rounded" style="width:1cm; height:1cm;"/>

image is displayed but width and height still have no effects. Grrr! 


UPDATE #4

IT WORKS NOW!!!!!  THANKS ALL. 


Avatar
Discard
Author

Somebody would have a idea for this?

Who did flag this post today almost a year later and for what reason?

Author

My error for the flag. Sorry

Best Answer

Hello Pascal

use this code instead of span


<img t-if="order_line.product_id.image_variant" t-att-src="'data:image/png;base64,%s' % order_line.product_id.image_variant" class="img-rounded" style="width:9cm; height:9cm;"/>

Change height and width in style which you want.

Thanks,

Avatar
Discard
Author

oh!!!! I will try this interesting code soon... thanks a lot.

Author

I have updated my Odoo files and it works now. Big thanks to you for your help!

Related Posts Replies Views Activity
0
May 24
327
2
May 24
961
3
Feb 24
812
2
Nov 22
3876
0
Apr 24
329