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

How to get images from db on QWeb report - Odoo 8

By
Alejandro Perez Cosio
on 12/17/14, 7:08 PM 5,837 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

+1 for this post. I will follow it.

Pascal Tremblay
on 12/17/14, 8:31 PM

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 Perez Cosio
on 12/17/14, 8:44 PM

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

Luke Branch
on 12/17/14, 8:59 PM

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!

Alejandro Perez Cosio
on 12/17/14, 9:04 PM
0
Alejandro Perez Cosio
On 12/17/14, 9:33 PM

@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!

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

Luke Branch
on 12/17/14, 10:16 PM
0
kirubanidhi
On 6/13/16, 8:57 AM

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>

0

Pascal Tremblay

--Pascal Tremblay--
1312
| 5 2 7
Alma, Canada
--Pascal Tremblay--


Pascal Tremblay
On 12/18/14, 8:30 AM

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?

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

3 follower(s)

Stats

Asked: 12/17/14, 7:08 PM
Seen: 5837 times
Last updated: 6/13/16, 8:57 AM