Odoo Help


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.


How to add image to the form in Odoo 8.0

Dr Obx
on 8/26/15, 7:41 AM 862 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 4 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

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)


Asked: 8/26/15, 7:41 AM
Seen: 862 times
Last updated: 8/26/15, 11:27 AM