如何在odoo 14中从向导创建excel.xlsx报告



如何在odoo 14中从向导生成xlsx报告。我在向导中制作了一个按钮

魔法.py

classReceivedReportWizard(models.TransientModel):
_name = 'po.goods.report.wizard'

def print_xls(self):
context = self._context
data = {
'ids': self.ids,
'model': self._name,}
return {
'type': 'ir.actions.report',
'data': {'model': 'po.goods.report.wizard',
'options': json.dumps(data, default=date_utils.json_default),
'output_format': 'xlsx',
'report_name': 'product receiving statement',
},
'report_type': 'xlsx'
}  

在xml 中

<record id="goods_received_details_xlsx" model="ir.actions.report">
<field name="name">product receiving report</field>
<field name="model">po.goods.report.wizard</field>
<field name="report_name">goods_received_report.report_goods_received_xlsx</field>
</record>

在报告中.py

_name = 'report.goods_received_report.report_goods_received_xlsx'
_inherit = 'report.report_xlsx.abstract'

def generate_xlsx_report(self, workbook, data, vendors):
format0 = workbook.add_format({'font_size': 14, 'align': 'vcenter', 'bold': True})
format1 = workbook.add_format({'font_size': 11, 'align': 'vcenter', 'bold': True})
format2 = workbook.add_format({'font_size': 8, 'align': 'vcenter', })
sheet = workbook.add_worksheet('Student Data Card')
sheet.write(2, 4, 'test Details', format0)

请建议如何在odoo14 中获得excel报告

您是否尝试过在向导视图xml中调用print_xls

<button name="print_xlx"/>

我不明白当你想打印xlsx时,为什么你用xml声明qweb pdf。要打印xlsx,您需要安装一个用于xlsx报告的新模块。

最新更新