Skip to Content
Menu
This question has been flagged
4 Replies
8064 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?

Avatar
Discard

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.

Best Answer

Hey Kris, Please see following link,

insert image / field in a report

Hope it works for you.

Avatar
Discard
Author

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

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?

Best Answer

I think this link will helpful to you:

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

Avatar
Discard
Author

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

Best Answer

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.

Avatar
Discard

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 :

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

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

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

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

@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 hello, did you finished to code the module ? Many thanks

Author Best Answer

Hi!

The method is working on V8?

Avatar
Discard

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

Author

Hi! Wil try out and see. Thank you!

Related Posts Replies Views Activity
1
Feb 16
3397
1
Mar 15
5618
0
Mar 15
4205
1
May 22
5961
0
Mar 16
3010