Hello!,
I have a binary fields and i need to fill it with a Image previously edited with PIL library, so for that i override default_get() function,
mapa=fields.Binary('')
@api.model
def default_get(self, fields):
resul = super(ModelMap, self).default_get(fields)
filepath='/odoo/odoo-server/addons/my_module/static/src/img/'
mapa = Image.open(filepath+'Map_odoo.png').convert('RGB')
**here i process mapa object**
until here its all ok, but now i try first:
mapa.save(filepath+'Mapa_odoo_temp.png')
resul['mapa']=filepath+'Mapa_odoo_temp.png'
but doesnt work, raise a "Permission denied" because i cannot create that file , not in the module path and in any other path either, and idk how solve this...
fo that i try another way,
map2=open(filepath+"Mapa_odoo_temp.png", "wb")
map2.write(base64.decodebytes(mapa))
map2.close()
resul['mapa']=filepath+'Mapa_odoo_temp.png'
but doesnt work too
so finally try giving the image directly
resul['mapa']=mapa
but this dont crash but dont display the image "the image cannot be loaded" or something similar.
Could somebody tell me how i could do? so thanks.