Odoo Help


This community 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.


save with same file name in 'ir.attachment'

on 7/13/15, 2:14 AM 659 views

Using ir.attachment saved one file in new module but its file extension in .bin file

how i can change it extension into given file name and extension ?   


Created new module to attach a file by using ir.attachment

when i attaching and downloading are working

but uploaded file is sample.png when i download file name is like okjddnjd.bin.

any solution ? to make same file name(sample.png) when it download..

Your question is not understandable. Please elaborate it and make an example.

Ermin Trevisan
on 7/13/15, 11:37 AM

@Ermin: He has uploaded an attachment but when he downloads it again it has the file extension .bin. He's wondering why that is happening and how he can fix it because he wants the original filename to be saved ;) @shaneebkan: Is this is a many2many, one2many or simply by uploading an attachment under 'more'? I know I saw some pull request a few days ago to fix this.

on 7/15/15, 1:53 AM

it a new module that inherit ir.attachment that many2one

on 7/15/15, 3:15 AM

Ankit H Gandhi(AHG)

--Ankit H Gandhi(AHG)--
| 5 3 6
Gandhinagar, India
--Ankit H Gandhi(AHG)--

Learning Python..

Ankit H Gandhi(AHG)
On 11/10/15, 2:56 AM

Dear Shaneebkhan,

You should add a field for filename and use it in the filename attribute of the binary field. You can keep this field visible or invisible as per your requirement. The following is the code example for the

class your_class(osv.Model):

_name = "yourclassname"

_description = "yourclassdescription"

_columns = {

'binary_field':fields.binary('Your binary field'),



And in the form view in your xml:

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

<field name="binary_field" readonly="1" filename="filename"/>

I hope this helps for you.

Thanks & Regards,

Ankit H Gandhi.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 7/13/15, 2:14 AM
Seen: 659 times
Last updated: 11/10/15, 2:56 AM