How to display a default image (saved in /my_module/static/img/car1.png) in a form ?
I have a binary field like this:
car_image =field.Binary(string="car1",default=??)
in xml, i gave like this:
<field name="car_image1" widget="image"/>
Please help
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- 客户关系管理
- e-Commerce
- 会计
- 库存
- PoS
- 项目
- MRP
此问题已终结
2
回复
5897
查看
| 相关帖文 | 回复 | 查看 | 活动 | |
|---|---|---|---|---|
|
|
1
11月 24
|
21281 | ||
|
|
1
9月 23
|
4075 | ||
|
|
3
5月 23
|
6637 | ||
|
|
7
4月 23
|
50159 | ||
|
|
1
12月 22
|
8709 |
I added a default function like this:
But it says "Image cannot be displayed"
@api.model
def _get_default_image(self):
f = open('static/description/car1.png','rb')
self.car_image1 = base64.b64encode(f.read())
f.close()
car_image1 = fields.Binary(string="CAR Image", default='_get_default_image')