Skip to content

Instantly share code, notes, and snippets.

@bitodoo
Created May 24, 2019 04:56
Show Gist options
  • Save bitodoo/75c279581c0d0aae4ae09845af249762 to your computer and use it in GitHub Desktop.
Save bitodoo/75c279581c0d0aae4ae09845af249762 to your computer and use it in GitHub Desktop.
import base64
from odoo import tools
@api.model
def _default_image(self):
image_path = get_module_resource('hr', 'static/src/img', 'default_image.png')
return tools.image_resize_image_big(base64.b64encode(open(image_path, 'rb').read()))
image = fields.Binary(
"Photo", default=_default_image, attachment=True,
help="This field holds the image used as photo for the employee, limited to 1024x1024px.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment