how to display image in form view and also in tree view?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
For List view:
<field name='image_256' string="Product Image" optional="show" widget="image"/>
On version 13.
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.
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>
you can try this
in .py file
image = fields.Binary(string="Image")
<group>
<field name='image' widget="image" class="oe_avatar" />
</group>
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>
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.
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký