Odoo Help


Are you able to control the width of a product variant image in PDF?

Pascal Tremblay
on 6/25/15, 3:15 PM 1,567 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 :


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



<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;}" />



But the width is still uncontrollable.


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

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! 



Somebody would have a idea for this?

Pascal Tremblay
on 4/26/16, 9:22 PM

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

Ermin Trevisan
on 4/27/16, 1:05 AM

My error for the flag. Sorry

Pascal Tremblay
on 4/27/16, 3:35 AM
Jaydeep Barot (jar)
On 4/27/16, 8:56 AM

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.


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

Pascal Tremblay
on 4/27/16, 9:39 AM

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

Pascal Tremblay
on 4/27/16, 8:17 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 6/25/15, 3:15 PM
Seen: 1567 times
Last updated: 4/27/16, 8:18 PM