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 add product image

By
Jack
on 5/31/13, 3:57 AM 4,995 views

Hiiii

how we can add product image as a field on the sales order when we add an item.

Thanks jack

Do you want to get an image on your report, or in the order within openERP?

patrick
on 5/31/13, 6:51 PM

Hi Patrick, I'm looking to implement images on the sales order, purchase order, quotation, and invoice lines for reports, are you aware of any method to implement this either in the RML files or with a module?

Luke Branch
on 7/3/14, 7:27 AM
2

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 5/31/13, 4:54 AM

Just create one related field in sale.order.line and display it in Order Line form view.

Try this:

`product_image`: fields.related('product_id', 'image_medium', type='binary', 'Product Image')

Add this field in sale.order form view in inline form view of sale.order.line.

As i am Beginner & i have inherited sale.order in new module....so please tell me how to write the related fields in py & xml file in the new module to have a proper output in which when we select a product we get the product image of selected product also there in the new field...

Jack
on 5/31/13, 5:55 AM

Hi Sudhir, Thanks for the instructions. I'm very new to Odoo v8 and am unaware how to implement what you have instructed. Should I be editing the the QWeb files by adding a field with the code inside the sale order line using the Odoo v8 developer mode, or is there another method that you would suggest? I am looking to get images on order lines in the following types of documents for PDF output: Sales Order, Quotation, Purchase Order, Invoice. I am also looking to include images on sales order/quotation lines for the CMS facing quote builder (ie. where a customer can review the quotation from the frontend). I am having some luck implementing this by borrowing some code from the shopping cart order lines, however I have not made much progress on editing the RML / QWeb reports that allow printing/saving to PDF for invoices, quotations, etc.

Luke Branch
on 7/4/14, 2:38 AM

Somebody has successfully put pictures in a quotation with this method?

Pascal Tremblay
on 12/5/14, 10:49 PM
2

Luke Branch

--Luke Branch--
1531
| 6 7 8
Mui Wo, Lantau, Hong Kong
--Luke Branch--

...

Luke Branch
On 7/4/14, 8:11 AM

If you are looking to add a product image to a printed report (ie. PDF or HTML) sales order, purchase order, invoice, or any other report with product order lines I believe I have figured out a solution thanks to Fabrice Henrion's post here: https://www.odoo.com/forum/Help-1/question/Is-there-any-way-to-preview-WebKit-report-layout-while-coding-maybe-WYSIWYG-Editor-52307.

Simply follow Fabrice's instructions as follows (preferably use latest master branch version):

  1. First you have to know that the new QWeb engine allows to output PDF or HTML. It is only when the output is HTML that it can be modified in a WYSIWYG fashion.
  2. Let's assume the Sales module is installed on a fresh Odoo instance. By default, the output of a quotation document is PDF, you can test that by printing a quotation. We want to change this.
  3. Make sure your user has the technical feature checkbox checked. Then go to Settings > Technical > Reports > Reports, then search "sale.order" and enter the record.
  4. Edit the Report Type from PDF to HTML, then Save.
  5. Go back to the Sales app and print a quotation.
  6. A popup appear (or your popup-blocker will notify you). You will see the quotation in that popup and a black bar at the top with the Edit button. You need to make sure you have the access right to edit this so I recommend you do this test as an admin.
  7. From there, it's pretty straightforward. You edit whatever you want. You have to realize that there are 2 types of edition on a record like this: editing this particular record, or editing the quotation template which will have an impact on all records. For example, if you edit a header, it will be a template edition.

If you want to add an image to an order line simply edit the HTML in the HTML editor found in the top navigation menu under Customize >> HTML Editor and find the place in the HTML/QWeb template that you would like to edit. I simply added an extra set of <th></th> tags as follows for a order line header (in the appropriate section of html/qweb that is):

<th class="text-left"><strong>Picture</strong></th>

and then added the following line for the sales order line product picture column:

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

The contents of the <span> tag pull the product image into the sales order line in the column that you want and when you save your html your report will display the appropriate product picture in 64px x 64px.

There may be a better way to do this and I welcome any comments on how this process might be improved.

Plouf! too hard and complicated. With my actual invoice software, I can drag n drop 10 pictures in one shot if I want.

Pascal Tremblay
on 12/5/14, 10:46 PM

@Pascal, This is teaching you how to customise reports in Odoo yourself. If you'd like to see that functionality in a ready-built module feel free to comment below with a list of features you'd like to see as I will be building a community module to help make this easier. What invoicing software are you using?

Luke Branch
on 12/5/14, 11:07 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

2 follower(s)

Stats

Asked: 5/31/13, 3:57 AM
Seen: 4995 times
Last updated: 3/16/15, 8:10 AM