0
votes

I'm generating a pdf and storing it on my server using Openerp.Can any one please tell me how to Force Download that file using Openerp.If can upload the pdf using fields.binary and download it automatically.But i don't want to store the file in database.I want to directly download it.Can any one help me.Thanks in advance

2

2 Answers

1
votes

I solved the issue by installing "Document Management System" module and attaching the files to "ir.attachment" instead of storing them as a binary field.Now you can download the document from the attachments.

code :

filename="/home/cryosave_qrcodes/xyz.pdf"
files = open(filename,'rb').read().encode('base64')
ir_values={
            'name':image_name,
            'datas_fname': image_name,
            'type':'binary',
            'datas':files,
            'create_uid':uid,
            'partner_id':ids[0],
            'res_model':'res.partner',
            'res_id':ids[0],
        }
 self.pool.get('ir.attachment').create(cr,uid,ir_values,context=context)
0
votes

Fetch what file you want use read and write function in python.

import os
path = os.path.join(os.path.expanduser(),('~'), 'documents', 'python', 'file.txt')
fh = open(path,"w")
fh.write("Hello World")
fh.close()