Odoo Help


save with same file name in 'ir.attachment'

on 7/13/15, 2:14 AM 1,804 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)--

| 6 5 6
Baroda, 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.

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.


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)


Asked: 7/13/15, 2:14 AM
Seen: 1804 times
Last updated: 11/9/16, 5:21 AM