1

I have a custom module where I add custom file upload fields like so:

my_upload_2d = fields.Binary(string="Upload 2D")
my_upload_3d = fields.Binary(string="Upload 3D")

The problem is that uploaded PDFs or Catia files are downloaded as .bin files - how can I see to it that the files are downloaded with the same name they have been uploaded with in the first place?

DROOM
  • 165
  • 9
  • You'll probably need to use a filename field for each of your Binary fields to track the names. See [this question](https://stackoverflow.com/questions/32835390/changing-the-filename-of-a-uploaded-binary-file-field) for some examples. – travisw Mar 14 '19 at 15:58

1 Answers1

2

You need a field for the file itself and another field for the file name, ie:

description_data_file = fields.Binary('description data')
description_data_file_name = fields.Char('description file name', size=80)

And in the xml file:

      <group string="File to import">
            <field name='description_data_file' string="Desc file" widget="binary"  filename="description_data_file_name"/>
            <field name='description_data_file_name' string="Desc file" attrs="{'readonly':True, 'invisible':True}" />
       </group>

Note that in the xml the binary data field relates to its name using the "filename" parameter.

Victor G.
  • 121
  • 5