Search Here

Write binary data into zip file and download 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

Post a Comment

7 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
  3. Hello dear, please whats the difference between the self.attachment and self.binary_field_name?

    ReplyDelete
    Replies
    1. dear there is no difference, actually self.attachment is a binary field name nothing else...
      attachment = fields.Binary(string='Attachment')

      Delete
  4. Hello dear, please; whats de difference between self.binary_field_name and self.attachment?

    ReplyDelete