Last active
August 29, 2015 13:57
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
from osv import osv, fields | |
class my_class(osv.osv_memory): | |
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): | |
f = open(record_browse.file_path) | |
result[record_browse.id] = base64.encodestring(f.read()) | |
f.close() | |
return result | |
_name = 'my.class' | |
_columns = { | |
'file_path': fields.char('File Location', size=128), | |
'file': fields.function(get_file, method=True, store=False, type='binary', string="Download File"), | |
} | |
my_class() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment