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
回覆
5863
瀏覽次數
| 相關帖文 | 回覆 | 瀏覽次數 | 活動 | |
|---|---|---|---|---|
|
|
1
11月 24
|
21235 | ||
|
|
1
9月 23
|
4015 | ||
|
|
3
5月 23
|
6602 | ||
|
|
7
4月 23
|
50096 | ||
|
|
1
12月 22
|
8667 |
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')