How to add a download hyperlink for downloading attachments from website in odoo

I want to add a hyperlink in the website module in odoo using which I can download the attachments which consists of information of the product which was created.Please help with with this problem . Thank you

It is too late to answer this question. Anyway it might be helpful to some one. I have googled more, since i didn't get any write solution.

Step 1: Create hyperlink for download button. In that button you need to pass

  1. model name
  2. field
  3. id
  4. filename (optional)

For an example your link should be like this

<a t-attf-href="/web/binary/download_document?model=product.brand.files&amp;field=file&amp;id={{ file.id }}&amp;file_name={{ file.file_name }}">

Step 2:

Create controller for above link. Ex

class Binary(http.Controller):
    @http.route('/web/binary/download_document', type='http', auth="public")
    @serialize_exception
    def download_document(self,model,field,id,file_name=None, **kw):
        """ Download link for files stored as binary fields.
        :param str model: name of the model to fetch the binary from
        :param str field: binary field
        :param str id: id of the record from which to fetch the binary
        :param str filename: field holding the file's name, if any
        :returns: :class:`werkzeug.wrappers.Response`
        """
        Model = request.env[model].sudo().search([('id', '=', int(id))])
        filecontent = base64.b64decode(Model.file or '')
        headers = werkzeug.datastructures.Headers()
        if not filecontent:
            return request.not_found()
        else:
            if not file_name:
                filename = '%s_%s' % (model.replace('.', '_'), id)
                headers.add('Content-Disposition', 'attachment', filename=filename)
                return request.make_response(filecontent,headers)
            else:
                headers.add('Content-Disposition', 'attachment', filename=file_name)
                return request.make_response(filecontent,headers)

It will work. Above code for Odoo 10. You can do the same for below versions also. I have got refer from this link

Cheers.

How to add a download hyperlink for downloading attachments from , Hello all, We are now able to download an attachement directly with an url like this� Hello Michel, if for example you have product that you set up in your back-end with the eCommerce, you can allow your customers to download a file after they buy a product, but configuring the digital product. A simpler and more direct version is to add a "click here" to download a file and you link it with a dropbox or a google doc. Hope it helps!

Here is a working example

return {
    'type': 'ir.actions.act_url',
    'url': '/web/content/%s/%s' % (attachment_id.id, shortname),
    'target': 'self',
    'nodestroy': False,
}

In short you just have to have a link that goes to /web/content/ir_attachment_id/the_name_you_want_the_file_to_have.

This works on Odoo V10 too.

How to create a public url to download an attachment?, Odoo Advance Website Product Attachments this module will make it easy to include user guides, software downloads, and other digital content app from our Webkul store you will get the link for downloading the zip file. Provide feature to add/show multiple attachments on the website. Associate Text Files, User Guides, pdf, etc, with your Products. Customers Can Filter Attachments by Category on the Frontend. View the Download Count for Each File Attachment. Categorize Each Attachment. Change attachment category sequence on Website.

this is work from odoo 10 you must try

<a t-attf-href="/web/content?model=website.support.ticket.message&amp;field=attachment&amp;id={{chat.id}}&amp;filename={{chat.attachment_filename}}&amp;download=true">Download</a> 

Odoo Advance Website Product Attachment, These customizations will disable attachment downloads for all users, including administrators. as they are in quotes, are comma separated and do not include the '. a.download-all-link { display: none !important; } a#download-all-link link � Unable to open PDF and PPT files using SSL and Internet� Hello Michel, if for example you have product that you set up in your back-end with the eCommerce, you can allow your customers to download a file after they buy a product, but configuring the digital product. A simpler and more direct version is to add a "click here" to download a file and you link it with a dropbox or a google doc. Hope it helps!

If this is for a form you could do this entirely in the view. First add a record entry somewhere in the xml file:

<record id="module_name.http_link" model="ir.actions.act_url">
  <field name="name">Button Name</field>
  <field name="type">ir.actions.act_url</field>
  <field name="target">new</field>
  <field name="url">https://your-http-link</field>
</record> 

And then in the form:

<button type="action" name="%(http_link)d" string="Name" class="oe_highlight"/>

How to disable attachment downloads, We at Emipro, got this question numerous times from different Odoo developers. So here I am giving the Step 1 : Create a method inside your regular model and return URL. Download link for files stored as binary fields. The download attribute is only used if the href attribute is set.. The value of the attribute will be the name of the downloaded file. There are no restrictions on allowed values, and the browser will automatically detect the correct file extension and add it to the file (.img, .pdf, .txt, .html, etc.).

How to download any file on button click ?, You can access all of them without being logged in as a user. For example: If you add this to the url of a runbot: http://[your odoo URL]/web/image/� After downloading AxysLauncher.exe, open the file properties and unblock it. Then copy the file to the Axys root folder. Each user that wants the hyperlink functionality needs to run it once and click the "Add/Update Registry", which tells Windows to call AxysLauncher when an axys:// hyperlink is clicked. AxysLauncher then processes

Many ir.attachment are unprotected available from the internet , How do I Create a Downloadable File in cPanel? In some instances you may find that you need to make a file available to download through your website. Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc. Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Creating a Downloadable File in cPanel, This module enables the feature to upload & download multiple attachments in the We need to create only one mail, attach more than one files and send to The “Attach a file” link will lead you to the file browser – from where we can Cost Savings: Email attachments can save money. Odoo 14 Features – Website� Based on the scheduled job 'Synchronize attachments from cloud' Odoo regularly checks whether: Any file is added / moved / removed in a OneDrive / SharePoint document folder. If yes, Odoo would create a link to this file in a target object (e.g. a new attachment to SO019) or would move / delete such an attachment.