This question has been flagged
8 Replies
21889 Views

Hello all,

I found the way to save an image at my DB using fields.Binary().
Now, I need to get that image on my QWeb report.. 
Do you know how to call that field from the Qweb report?

Thanks in advance!

Regards
Alejandro

Avatar
Discard

+1 for this post. I will follow it.

Author

A real use-case could be "how to print the field product_template.image on a QWeb report" since that field is a binary type.

@Alejandro, are you storing the image in a one2many relationship (eg. order lines), or is this just a single field that you would like to include on a report? Please let me know what report you are working on and how you would like to display the field (eg. a t-foreach t-as type loop - eg. order lines). I've already built a theme module that includes heavy modification of the default quotation, sales order, invoice, etc. reports. I'll be separating this into a standalone module here: https://github.com/OdooCommunityWidgets/product_extended_report_order_lines over the next few days if that is any help.

Author

Hello @Luke, I'm working with a single binary field 'product_template.image'. I would like to include that image on a QWeb report. Thank you for your interest!

Author Best Answer

@Luke, I found a response from you for a similar question (\source)

Now I'm printing the image in the QWeb report this way:

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

Thank you!

Avatar
Discard

@Alejandro, no problem, i'm glad it helped.

Best Answer

Hello Alejandro Perez Cosio,

     In  my code is working fine, 
Staff_id is a many2one fields. Staff_image field is having staff table. Im accessing a field from staff table image field into my student table.
doc.staff_id.staff_image


<div class="col-xs-4 col-xs-offset-3">

            <strong text-align="right">Staff Image</strong>

            <span t-field="doc.staff_id.staff_image"

t-field-options='{"widget": "image","class": "oe_avatar"}' />

</div>

Avatar
Discard
Best Answer

Look at this...

in report_purchasequotation_document, I can get image with code :

            <h2>Request for quotation : N° <span t-field="o.name"/></h2>
            <table class="table table-condensed">
                <thead>
                    <tr>
                        <th class="text-left"><strong>   Picture</strong></th>
                        <th class="text-left"><strong>Description</strong></th>
                        <th class="text-center"><strong>Expected date</strong></th>
                        <th class="text-right"><strong>Quantity</strong></th>
                    </tr>
                </thead>
                <tbody>
                    <tr t-foreach="o.order_line" t-as="order_line">
                        <td>
                             <span t-field="order_line.product_id.image_small" t-field-options="{&quot;widget&quot;: &quot;image&quot;, &quot;class&quot;: &quot;img-rounded&quot;}"/>
                        </td>
                        <td>
                             <span t-field="order_line.name"/>
                        </td>
                        <td class="text-center">
                                <p t-field="order_line.date_planned" t-field-options='{"format": "d MMMM y"}'/>
                        </td>
                        <td class="text-right">
                            <span t-field="order_line.product_qty"/>
                            <span t-field="order_line.product_uom" groups="product.group_uom"/>
                        </td>
                    </tr>
                </tbody>
            </table>

 

In report_saleorder_document, I can NOT get image with code :

            <table class="table table-condensed">
                <thead>
                    <tr>
                        <th> Picture</th>
                        <th>Description</th>
                        <th>Taxes</th>
                        <th class="text-right">Quantity</th>
                        <th class="text-right">Unit price</th>
                        <th groups="sale.group_discount_per_so_line">Disc.(%)</th>
                        <th class="text-right">Price</th>
                    </tr>
               </thead>
               <tbody class="sale_tbody">
                    <tr t-foreach="o.order_line" t-as="l">
                        <td>
                           <span t-field="l.product_id.image_small" t-field-options="{&quot;widget&quot;: &quot;image&quot;, &quot;class&quot;: &quot;img-rounded&quot;}"/>
                        </td>
                        <td><span t-field="l.name"/>
                       </td>
                        <td>
                            <span t-esc="', '.join(map(lambda x: x.name, l.tax_id))"/>
                        </td>
                        <td class="text-right">
                            <span t-field="l.product_uom_qty"/>
                            <span groups="product.group_uom" t-field="l.product_uom"/>
                        </td>
                        <td class="text-right">
                            <span t-field="l.price_unit"/>
                        </td>
                        <td groups="sale.group_discount_per_so_line">
                            <span t-field="l.discount"/>
                        </td>
                        <td class="text-right">
                            <span t-field="l.price_subtotal" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.pricelist_id.currency_id&quot;}"/>
                        </td>
                    </tr>
                </tbody>
            </table>

 

Do you see the problem guy?

Avatar
Discard