Reputation: 1232
Anyone now how to set default value for fields.binary ?
I succeed to put data in the fields.binary with the default_get() method, but when I try to open the file (by clicking 'Save As' button), I get this error message :
Firefox cannot find the file at the address http://172.17.0.2:8061/openerp/form/save_binary_data?_terp_field=template_file&_terp_model=import_batch_number&_terp_id=F
Upvotes: 0
Views: 499
Reputation: 1232
There is an issue because the displayed record is not yet saved in DB, so OpenERP cannot get the document stored in fields.binary.
I created the document before open the view and it's work well.
Upvotes: 0
Reputation: 1315
Try to use this code
import base64
binary_field=fields.Binary(string='Image',default='get_default_image')
def get_default_image(self):
with open("yourfile_path.ext", "rb") as image_file:
self.binary_field = base64.b64encode(image_file.read())
Hope this helps.
Upvotes: 2