i want to be able to add default image in wizard form .
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ờ
You can use default_get method. For eg.
@api.model
def default_get(self, fields):
rec = super(Your_Class_Name, self).default_get(fields)
context = dict(self._context or {})
active_model = context.get('active_model')
active_ids = context.get('active_ids', [])
Use 'default_get' method to assign a default image.
Check these links for reference.
(docs)
https://www.odoo.com/documentation/8.0/reference/orm.html#openerp.models.Model.default_get
(example)
https://github.com/odoo/odoo/blob/8.0/addons/account/account.py#L3085
Hi,
For Odoo 10.
from odoo.modules.module import get_module_resource
product_image = fields.Binary(
string='Global Product Image',
default=lambda s: s._default_product_image(),
help='Use as the global image for all product default images. '
'Limited to 1024x1024.',
)
@api.model
def _default_product_image(self):
image_path = get_module_resource(
'module_name', 'static/src/img', 'glob_prod_img.png'
)
with open(image_path, 'rb') as handler:
image_data = handler.read()
return tools.image_resize_image_big(
image_data.encode('base64')
)
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ýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 3 15
|
6843 | ||
Close wizard after print report
Đã xử lý
|
|
3
thg 2 24
|
12637 | |
|
2
thg 8 22
|
8920 | ||
|
2
thg 4 19
|
9686 | ||
|
0
thg 3 25
|
1264 |