XLSX报告应在Odoo10的单页中显示

时间:2018-11-17 08:31:22

标签: report odoo xlsx odoo-10

我为客户列表生成xlsx报告,并根据4位客户的个人客户明智方法生成的报告生成了4张纸。但是,我想要一张工作表来列出多个客户。

我的代码和屏幕截图在这里:

from odoo.addons.report_xlsx.report.report_xlsx import ReportXlsx

class PartnerXlsx(ReportXlsx):
    def generate_xlsx_report(self, workbook, data, partners):
        for obj in partners:
            report_name = obj.name
            print("REPRTTTTTTT", report_name, report_name[:31])
            # One sheet by partner
            sheet = workbook.add_worksheet(report_name[:31])
            bold = workbook.add_format({'bold': True})
            sheet.write(0, 0, obj.name, bold)
            sheet.write(0, 1, obj.email, bold)
            sheet.write(0, 2, obj.telephone, bold)
PartnerXlsx('report.res.partner.xlsx', 'res.partner')

现在:为5个客户生成5张纸 enter image description here

要求:所有用户一张纸 enter image description here

1 个答案:

答案 0 :(得分:0)

尝试以下代码:

from odoo.addons.report_xlsx.report.report_xlsx import ReportXlsx

class PartnerXlsx(ReportXlsx):
   def generate_xlsx_report(self, workbook, data, partners):
       sheet = workbook.add_worksheet(report_name[:31])
       counter = 0
       for obj in partners:
          report_name = obj.name
           print("REPRTTTTTTT", report_name, report_name[:31])
          # One sheet by partner

            bold = workbook.add_format({'bold': True})
            sheet.write(counter, 0, obj.name, bold)
            sheet.write(counter, 1, obj.email, bold)
            sheet.write(counter, 2, obj.telephone, bold)
            counter = counter + 1
PartnerXlsx('report.res.partner.xlsx', 'res.partner')