Odoo Help


How to add image to the form in Odoo 8.0

Dr Obx
on 8/26/15, 7:41 AM 1,958 views

New API, how to add image from specified location based on < field name="item_nr"/>, this field will contain number related to the image ...

create link or load directly into form ?




| 6 5 7
Tbilisi, Georgia
On 8/26/15, 8:41 AM

option 1 (same image in all records, may be externally stored, inserting by url):

you can mix html & form record, so you can add any image (if you have link to it) using ordinary HTML img tag, so in your form:

<record id="some_id" model="ir.ui.view">
<field name="arch" type="xml">
<form string="Some STR">
<sheet> ....
<img src="http://example.com/some.jpg" style="width:300;height:200;"/>

option 2 (different image per record, stored in odoo using binary field):

If you'll use binary field (the fields.Binary one...) to store images in odoo, then you can use widget="image" in your xml, example:

<field name="my_binary_field_name" widget="image" />

(of course you've to add "my_binary_field_name" binary field in your model as well, in python code...) 

see example here: Odoo_8.0/openerp/addons/base/res/res_company_view.xml#L22 

option 3 (different image per record, possibly externally stored, inserting by url using custom widget):

say field "image_url" is a char field containing image url, or such a part of it (as your number in "item_nr"?) that makes it possible to build full url, then in your XML you'll have:

<field name="image_url" widget="my_image_widget" />

here "my_image_widget" is a custom widget you've to implement in javascript. you should generate ordinary html image tag (similar to one in option 1) from inside your custom widget, using value of "image_url" field.

there may be more/better options... good luck ;)

on 8/26/15, 8:42 AM

Nice effort Temur ! +1

Emipro Technologies Pvt. Ltd.
on 8/27/15, 1:48 AM

Nice answer

Bonnet Denis
on 8/9/17, 9:27 AM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)


Asked: 8/26/15, 7:41 AM
Seen: 1958 times
Last updated: 8/9/17, 9:27 AM