Bitodoo action button download

by
Odoo
v 10.0 v 11.0 Third Party 35
Download for v 10.0 Deploy on Odoo.sh
Availability
Odoo Online
Odoo.sh
On Premise
Technical Name bo_btn_download_file
Websitehttps://bitodoo.com/
Versions 11.0 10.0
You bought this module and need support? Click here!

README ---> https://github.com/bitodoo/odoo/tree/11.0/bo_btn_download_file

Example

In view::
<button name="print_late_comming" class="oe_highlight" string="Late comming PDF" type="object"/>
<button name="print_late_comming_xls" class="oe_highlight" string="Late comming XLS" type="object"/>
In python::
import xlsxwriter
from io import BytesIO
from odoo.modules.module import get_module_resource
def pdf_file(self):
pdf_path = get_module_resource('bo_btn_download_file', 'files', 'pdf_file.pdf')
return open(pdf_path, 'rb').read()
def print_late_comming(self):
self.ensure_one()
return self.env['ir.actions.act_url'].binary_content(model=self._name, method='pdf_file', id=self.id, filename='pdf_file.pdf', mimetype='application/pdf')
def xls_file(self):
output = BytesIO()
wb = xlsxwriter.Workbook(output, { 'default_date_format': 'dd/mm/yyyy' })
sheet.write(0, 0, "Company:", wb.add_format({'bold': True}))
wb.close()
output.seek(0)
return output.read()
def print_late_comming_xls(self):
self.ensure_one()
return self.env['ir.actions.act_url'].binary_content(model=self._name, method='xls_file', id=self.id, filename='xls_file.xls', mimetype='application/octet-stream')
Model return file:
ir.actions.act_url
Method:
binary_content(model=self._name, method='xls_file', id=self.id, filename='xls_file.xls', mimetype='application/octet-stream')
Params::
All params required
  • model: Model name
  • method: Method return out binary
  • id: Id record
  • filename: Name & extension file
  • mimetype: Mimetype

Please log in to comment on this module

  • The author can leave a single reply to each comment.
  • This section is meant to ask simple questions or leave a rating. Every report of a problem experienced while using the module should be addressed to the author directly (refer to the following point).
  • If you want to start a discussion with the author, please use the developer contact information. They can usually be found in the description.
Please choose a rating from 1 to 5 for this module.