Skip to Content
Menu
This question has been flagged
6 Replies
50043 Views

how to display image in form view and also in tree view?


Avatar
Discard
Best Answer

For List view:

<field name='image_256' string="Product Image" optional="show" widget="image"/>

On version 13.

Avatar
Discard
Best Answer


Define Image field

image = fields.Binary()
<field name="image" widget="image"/>

If you want to show this on tree view, download web_tree_image  for your version.

Define in tree view and set widget="image"

Watch on YouTube to see how to implement this.


Avatar
Discard
Best Answer

in xml file use <img> tag like this,

<form string='Class'>
    <sheet>
        <group>
            <field name='name'/>
            <img src='/module_name/static/image/myimage.png'/>
        </group>
    </sheet>
</form>
Avatar
Discard
Best Answer

you can try this 

in .py file

image = fields.Binary(string="Image")


<group>

        <field name='image' widget="image" class="oe_avatar" />

</group>

Avatar
Discard
Best Answer

Display image in tree view odoo10

<record id="personal_info_tree_view" model="ir.ui.view">

<field name="name">Personal Information</field>

<field name="model">personal.info</field>

<field name="arch" type="xml">

<tree string="Personal Info"> <field name="full_name"/>

<field name="image" nolabel="1" widget="image" class="oe_right oe_avatar"/>

</tree>

</field>

</record>

Avatar
Discard
Best Answer

You have to import the module which you need.

In view file, give <field name="image_small"/> in field tag.

In python file add the column as 'image_small' : fields.binary('Product Image'), Here the image will be binary type. Give the name you need for the image should be in ().

res['value'].update({'image_small': product_obj.image_small or False}) this will updates the products in product_object with the image_small.

res['image_small'] = line.image_small This will helps to display image in tree view.

Avatar
Discard