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.

1

OpenERP 7: How can I add images in sale.oder.line generally?

By
Kris Krnacs
on 5/30/13, 8:10 AM 3,864 views

I am having problems with adding images in reports(sxw). I add a new column in to my sale.order report /.sxw/ and put the already showing context like: [[ format(line.name) ]] or [[ formatLang(o.amount_untaxed, dp='Account', currency_obj=o.pricelist_id.currency_id) ]] it is working and showing on the printed .pdf file and/or e-mail. In other case if I put the [[product_id.product_image]] it is not showing up, it is only gives some nothing or alphanumeric values. It seem it is not the problem with the .sxw file, but the product image location pathname. Can anyone tell how to put the product image on place?

Hi Kris, Are you using v8 (ie. master) or v7? I have figured out a way to do this for v8 (master) using this post: https://www.odoo.com/forum/Help-1/question/Is-there-any-way-to-preview-WebKit-report-layout-while-coding-maybe-WYSIWYG-Editor-52307 Specifically the post from Fabrice. Please let me know if you are using v8 and I will post back with an answer for you.

Luke Branch
on 7/4/14, 6:24 AM
1

Luke Branch

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

...

Luke Branch
On 7/4/14, 8:15 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 v8 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.

Dear Luke, I'm trying to do just that (inserting pictures in each line of a quotation). I've run through the 7 steps with no problem. But when I click on Customize → HTML editor, I can see several templates (web_layout, (...) report_saleorder) but no one (not even report_saleorder) won't give me a lot of code to play with. Here is the html code I have for report_saleorder. As you can see, no place to add a relevant

or section :
DOMALYS
on 11/21/14, 9:45 AM

http://imageshack.com/a/img908/9149/CrGO9e.png

DOMALYS
on 11/21/14, 9:46 AM

@Naoli, I think some of the templates have changed since the time I wrote this post originally. Could you tell me what version of Odoo you are running and whether you are running on a local install or on Odoo's hosted option (ie. *.odoo.com)? I've built a basic module that adds this functionality that I can provide a github link to if you are running on a local instance. What custom fields do you need on your quotation? I've currently added fields for product image, stock code/internal_reference, customer(s) stock codes and a few other fields for my own requirements, but I can provide some basic instructions on how to add further custom fields if needed.

Luke Branch
on 11/21/14, 10:57 PM

Dear Luke, I'm running a local instance of Odoo v8 on my own server. I am not familiar with github but if you can provide me the link, that would be wonderful. I'll try to manage it. I just need to add the product image in the first column Many many thanks

DOMALYS
on 11/26/14, 6:26 AM
Dear Luke,
 I'm running a local instance of Odoo v8 on my own server. I am not familiar with github but if you can provide me the link, that would be wonderful. I'll try to manage it. I just need to add the product image in the first column 
Many many thanks

2014-11-22 4:57 GMT+01:00 Luke <luke-weairsoft-com@mail.odoo.com>:

@Naoli, I think some of the templates have changed since the time I wrote this post originally. Could you tell me what version of Odoo you are running and whether you are running on a local install or on Odoo's hosted option (ie. *.odoo.com)? I've built a basic module that adds this functionality that I can provide a github link to if you are running on a local instance. What custom fields do you need on your quotation? I've currently added fields for product image, stock code/internal_reference, customer(s) stock codes and a few other fields for my own requirements, but I can provide some basic instructions on how to add further custom fields if needed.

--
Luke
Sent by OpenERP S.A. using Odoo about Forum Post False
DOMALYS
on 12/15/14, 5:25 AM

@Naoli, I have not created the module yet, however I will throw something basic together tomorrow that will achieve this in this repository: https://github.com/OdooCommunityWidgets/product_image_report_order_lines/tree/8.0 I'd recommend signing up for a github.com account and watching the repository. I'll post back here once it is finished.

Luke Branch
on 12/15/14, 6:13 AM

@Luke hello, did you finished to code the module ? Many thanks

DOMALYS
on 2/3/15, 9:53 AM
1

Ghanshyam Prajapati

--Ghanshyam Prajapati--
1377
| 4 4 8
Pune, India
--Ghanshyam Prajapati--
OpenERP Developer
Ghanshyam Prajapati
On 5/30/13, 8:41 AM

Hey Kris, Please see following link,

insert image / field in a report

Hope it works for you.

Thank you! Yes it is the "old way" it is not working in openerp 7. Or you have some ideas?

Kris Krnacs
on 5/30/13, 11:02 AM

Hi Kris, i'm also interested in implementing this in v8, did you figure out a way to implement this either by customising RML files or via a module?

Luke Branch
on 7/3/14, 7:29 AM
1
jamesbale
On 5/30/13, 8:40 AM

I think this link will helpful to you:

https://accounts.openerp.com/forum/Help-1/question/483#501

Thank you! As you see it is only for tree view... My post is on the page already, down under the solution section, my post is the last one... Thank you anyhow

Kris Krnacs
on 5/30/13, 11:01 AM
0
Kris Krnacs
On 3/3/15, 9:14 AM

Hi!

The method is working on V8?

@Kris,

Which method are you referring to? I've got my method working for me own instances in printed reports, and have another method from Stefan's module here:

https://github.com/OCA/web/tree/8.0/web_tree_image

for live tree view.

Luke Branch
on 3/3/15, 10:06 PM

Hi! Wil try out and see. Thank you!

Kris Krnacs
on 3/4/15, 9:18 AM

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/30/13, 8:10 AM
Seen: 3864 times
Last updated: 3/16/15, 8:10 AM