I'm using Odoo 8 version.
I have created a new model called enquiry_customer_date
In that model, I have set following four fields.
I have given mention model one2many relationship with res.partner model
I have used below code for display records.
<field name="enquiry_from_customer_ids">
<tree string="Enquiry Lines">
<field name="enquiry_date"/>
<field name="file_name" invisible="1"/>
<field name="excel_file" filename="file_name"/>
</tree>
</field>
This will display correct file name in list view.
Face Problem:
When I download link, it stores with file name = base64 with .bin extension.
Question:
How to get working download link same as uploaded file name with extension in one2many field?
UPDATED
I have tried with @danidee answer.
System configuration parameter:
Treeview/Listview one2many field
OUTPUT:
Expected Output:
File should be downloaded with "Openerp_Customization_Needed.txt"
By default files and attachements are stored in the db as binary files, but you can change that behaviour by setting the ir_attachement.location
parameter
Got to Settings/Parameters/System Parameters
, look for ir_attachment.location
it should be set to db
change it to
file:///filestore
Note that the existing attachments and files will still be stored in the database, but any new attachment or file uploaded will be stored in the file system, which should enable you to download the file in it's original form like you wanted
Yes, you can export file as like you have uploaded via adding button in tree view instead of directly giving binary field name in treeview. Please add below code in enquiry_customer_date model
@api.multi
def export_file( self ):
return {
'type' : 'ir.actions.act_url',
'url': '/web/binary/saveas?model=ir.attachment&field=datas&filename_field=self.file_name&id=%s' % ( self.excel_file.id ),
'target': 'self',
}
Add the below code in your xml file,
<field name="enquiry_from_customer_ids">
<tree string="Enquiry Lines">
<field name="enquiry_date"/>
<field name="file_name" invisible="1"/>
<field name="excel_file" filename="file_name"/>
<button name="export_file" string="Download" type="object" icon="gtk-ok" class="oe_highlight" />
</tree>
</field>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With