Skip to Content
Menu
This question has been flagged
1 Reply
6325 Views

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.

Avatar
Discard
Author Best Answer
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

Avatar
Discard
Related Posts Replies Views Activity
5
Apr 20
3525
1
Mar 16
2002
2
Sep 21
7078
1
May 18
11599
2
Jun 24
6258