Untitled

mail@pastecode.io avatar
unknown
python
3 years ago
653 B
2
Indexable
Never
    def export_excel(self):
        ...
        ...
        
        fp = BytesIO()
        wb.save(fp)
        export = self.env['export.sale.order.lines'].create({
            'filename': self.name + '.xlsx',
            'excel_file': base64.b64encode(fp.getvalue()),
        })
        action = {
            'name': self.name + '.xlsx',
            'type': 'ir.actions.act_url',
            'url':
                "web/content/?model=export.sale.order.lines&id=" + str(export.id) + "&filename_field=filename"
                "&field=excel_file&download=true&filename=" + export.filename,
            'target': 'new',
        }
        return action