Odoo Help

0

How to download files which are attached in default attachments with original file extensions?

By
vadivel
on 11/9/16, 4:45 AM 752 views

Hi,

I need a solution for attachments.When i attach a file(.pdf or .jpeg or .png or .doc or .xls) in attachments on top of any form, once i download that file means, it is downloaded with some other unrelated name and without file extension.Can anyone have solutions to resolve this bug.Thanks in advance.

4

Ameera PP

--Ameera PP--
--Ameera PP--


Ameera PP
On 11/9/16, 5:23 AM

class myclass(osv.Model):

_name = "myclassname"

_columns = {

'binary_field':fields.binary('File'),

'file_name':fields.char('Filename'),

}

And in the form view in your xml:

<field name="filename" invisible="1"/>

<field name="binary_field" filename="file_name"/>

 

0
Sehrish
On 3/28/18, 4:11 AM

You can achieve this using binary fields.Binary Fields Store file encoded in base64 in bytea column in your created table.

create binary field in models.py (in your desired model)

 attachment = fields.Binary(string="Attachment")    
store_fname = fields.Char(string="File Name")

In your xml file create below fields.

<field name="store_fname" invisible="1" />
<field name="attachment" filename="store_fname"/>

 

Now when ever you will upload some file (.pdf,.xlx,.doc etc) it will be downloaded with same name and with file extension.

For more reverence visit: http://learnopenerp.blogspot.com/2016/06/using-binary-fields-in-odoo.html

Hope it helps you and others.

Thanks

For more reverence visit: http://learnopenerp.blogspot.com/2016/06/using-binary-fields-in-odoo.html

Hope it helps you and others.

Thanks

Sehrish
on 3/28/18, 4:12 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 11/9/16, 4:45 AM
Seen: 752 times
Last updated: 3/28/18, 4:11 AM