Skip to Content
Menu
This question has been flagged

I can´t get images on each line of a quotation PDF report to show. 

The steps i went through are:

  1. Active the developer mode (the bettle is shown)
  2. Navigate to Sales > Studio > Reports
  3. Choose sale.report_saleorder_raw or sale.report_saleorder
  4. Add a column next to Description
  5. In the new column: Insert Field > Product product_id (many2one) > Arrow > Image Image_128 (binary)
  6. Save

This is the code generated:

<data>

    <xpath expr="/t[@t-name='sale.report_saleorder_document']//t[@t-call='web.external_layout']//th[@name='th_description']" position="before" meta-name="th_description" meta-class="text-start">

      <th>

        <div>Imagen</div>

      </th>

    </xpath>

  </data>

  <data>

    <xpath expr="/t[@t-name='sale.report_saleorder_document']//t[@t-call='web.external_layout']/div/table/tbody/t[4]/t[10]/tr[@name='tr_section']/t[3]" position="after" meta-t-if="not show_section_total">

      <td>

        <p>

          <span data-oe-demo="Imagen 128" t-field="line.product_id.image_128" t-options-widget="'image'" t-options-qweb_img_raw_data="1"/>

        </p>

      </td>

    </xpath>

  </data>

Avatar
Discard
Best Answer

Hi,

In Odoo 19 Online, images often fail to appear on PDF reports such as quotations or invoices because the reporting engine (wkhtmltopdf) cannot render binary image fields directly. When you insert a product image field (like image_128) through Studio, Odoo adds a <span> with a t-field, which works in web views but not in PDFs. The proper way to display images in PDF reports is to convert the binary data into a base64 string and embed it within an <img> tag using QWeb’s t-att-src attribute.


To fix the issue, edit your quotation report in Developer Mode (Sales → Studio → Reports → Sale Order / Quotation) and open the XML editor. Then replace your current code for the image column with the following snippet, which correctly embeds the product image so it appears when printing to PDF:


<data>

  <xpath expr="//th[@name='th_description']" position="before">

    <th>Image</th>

  </xpath>


  <xpath expr="//tbody/tr/td[@name='td_description']" position="before">

    <td>

      <img t-att-src="'data:image/png;base64,%s' % (line.product_id.image_128 or '')"

           style="max-height:50px; max-width:50px;" />

    </td>

  </xpath>

</data>


This approach converts each product’s binary image into a base64-encoded format that wkhtmltopdf can render, ensuring the image prints correctly on each line of your quotation. You can adjust the max-height and max-width values to control image size


Hope it helps.

Avatar
Discard
Best Answer

Hello Lorena,
I believe that you don't need to add a field via studio because every product has own image field.

You can try this:
<span t-esc="line.product_id.image_128"

                    t-options="{'widget': 'image', 'max_width': '64', 'class': 'rounded'}"/>

Avatar
Discard
Related Posts Replies Views Activity
3
Oct 25
745
0
Oct 25
214
1
Oct 25
1914
2
Oct 25
334
0
Oct 25
738