Odoo Help

Welcome!

This community 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.

0

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

By
Pascal Tremblay
on 6/25/15, 3:15 PM 927 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. 


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

Thanks,

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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