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

I have more then 500 images in .jpg format, and all are less than 50kbs. 

All images have ID, and all employees have the same ID.

I am using Odoo 10.

Avatar
Discard
Best Answer

Hi,

This code get all files on image_dir and use files names as an id to update employees.

You can use it in a specific odoo module or via a python web-service.

image_dir = 'Path to your image folder'
for root, dirs, filenames in os.walk(image_dir):
for f in filenames:
self.env['hr.employee'].write(int(f.split('.')[0]),{'image':base64.encodestring(open(os.path.join(root, f), 'rb').read())})

 Best regards

Avatar
Discard