Search 1.9 billion lines of Odoo code on GitHub

custom_download_file

Author: Erick Navarro
License: no license
Branch: 11.0
Repository: cesaraugustochirinos/custom_download_file
Dependencies: base, and web
Languages: JavaScript (36, 37.9%), Python (41, 43.2%), XML (10, 10.5%), and reStructuredText (8, 8.4%)
Other branches: 7.0, and 8.0
Other repositories: 111sree/custom_download_file, Capriatto/custom_download_file, Guobower/custom_download_file, IJOL/custom_download_file, amarildogolloshi/custom_download_file, consultingerp/custom_download_file, cubicerpdev/custom_download_file, dsasoftware/custom_download_file, edanpiro/custom_download_file, erickgnavar/custom_download_file, georgeppts/custom_download_file, gitlabuser/custom_download_file, guidev224/custom_download_file, haylahi/custom_download_file, hxsam/custom_download_file, mario21ic/custom_download_file, odooerpperu/custom_download_file, one2pret/custom_download_file, pythoner-3k/custom_download_file, qq470647251/custom_download_file, sc4you/custom_download_file, and yasmanycastillo/custom_download_file

<h1 class="title">Custom Download File Odoo module</h1> <p>Widget for download a customized file</p> <a name="generic-custom-file"></a> <h2>Generic custom file</h2> <pre> <code lang="python">class MyFile(models.AbstractModel): _inherit = 'download.file.base.model' _name = 'my.file' def setup(self, record_id): super().setup(record_id) # initialize values def get_filename(self): return 'filename' def get_content(self): # process a file and return content return 'file_content'</code> </pre> <pre> <code lang="xml">&lt;widget name=&quot;custom_download_button&quot; model=&quot;my.file&quot; string=&quot;Download this file&quot;/&gt;</code> </pre> <a name="excel-report-example"></a> <h2>Excel report example</h2> <pre> <code lang="python">from StringIO import StringIO import xlsxwriter class MyExcelReport(models.TransientModel): _inherit = 'download.file.base.model' _name = 'my.excel.report' def get_filename(self): return 'my_report.xlsx' def get_content(self): output = StringIO() wb = xlsxwriter.Workbook(output) sheet = wb.add_worksheet('sheet1') # make something wb.close() output.seek(0) return output.read()</code> </pre> <pre> <code lang="xml">&lt;widget name=&quot;custom_download_button&quot; model=&quot;my.excel.report&quot; string=&quot;Download Excel file&quot;/&gt;</code> </pre>