How to Store Image in binary field from system path in odoo ?
def get_file(self, cr, uid, ids, field_name=None, arg=None,context=None):
result = dict.fromkeys(ids)
for record_browse in self.browse(cr, uid, ids):
addons_path = http.addons_manifest['web']['addons_path']
f = open(os.path.join(addons_path,'modulename','static','src','img', 'image.png'), 'rb')
result[record_browse.id] = base64.encodestring(f.read())
f.close()
return result
_columns = {
'web_icon': fields.function(get_file, method=True,store=False,type='binary',string="Download File"),
}
No comments:
Post a Comment