Search Here

Pages

Thursday, 25 June 2020

Write binary data into zip file and downlaod it on button click in odoo

In this tutorial I am going to show you how to write binary field data into zip file and download it on Odoo button click event.

Write binary data into zip file and downlaod it on button click in odoo

Download zip file on button click in Odoo

The scenario is we have an attachment or file (in binary format) in our database (PostgreSQL) and we want to download that file or attachment in .zip or .rar extension on button click. To do that I am going to use python library named "zipfile". This is python standard library, so we don't need to install it explicitly.



Don,t forgot to share, keep sharing keep learning

4 comments:

  1. object_name = self.binary_field_name
    here what binary_field_name contains can you please tell me

    ReplyDelete
    Replies
    1. in odoo binary field looks like

      attachment = fields.Binary(string='Attachment')

      that contains files

      Delete
  2. hi, is there a way to download a file from other website and pass to user, without save to server?

    ReplyDelete