Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
7454 มุมมอง

I want to set default product image, if we create a product but we dont upload image, there's no Camera with cross image? but another image, yesterday i was look a module for set it, but it's for Odoo 10 only, i installed but cant.

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด
import base64
from odoo import models, fields
from odoo import modules


def get_default_img():
with open(modules.get_module_resource('my_module', 'static/img', 'my_image.png'),
 'rb') as f:
return base64.b64encode(f.read())



class MyModel(models.Model):
_name = 'my.model'

field_binary = fields.Binary(default=get_default_img())

This is the answer, thread will be closed, thanks


src : https://www.iwesabe.com/blog/how-to-set-default-image-for-binary-field-odoo

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

For odoo18 if you want to do it for the website image you should check the product/static/src/img/product_thumbnails.png . Here is the place where comes the default image for website for example. If you want to change it and set another default image you just inherit the method where it is used and replace it with your own static image. Just did it worked. Good luck!

for help you can email me info@nimexsolutions.com

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
5
เม.ย. 20
4363
1
มี.ค. 16
2002
Contact image via url แก้ไขแล้ว
2
ก.ย. 21
8227
1
พ.ค. 18
12541
2
มิ.ย. 24
7467