I am trying to create an xlsx
report. I tried below code but getting an error:
Traceback (most recent call last): File "/home/shar/Projects/git/odoo/addons/web/controllers/main.py", line 72, in wrap return f(*args, **kwargs) File "/home/shar/Projects/git/odoo/addons/web/controllers/main.py", line 1485, in index request.session.db, request.session.uid, request.session.password, report_id]) File "/home/shar/Projects/git/odoo/odoo/http.py", line 118, in dispatch_rpc result = dispatch(method, params) File "/home/shar/Projects/git/odoo/odoo/service/report.py", line 35, in dispatch res = fn(db, uid, *params) File "/home/shar/Projects/git/odoo/odoo/service/report.py", line 142, in exp_report_get return _check_report(report_id) File "/home/shar/Projects/git/odoo/odoo/service/report.py", line 120, in _check_report raise UserError('%s: %s' % (exc.message, exc.traceback)) UserError: (u"Unknown report type: xlsx: (, NotImplementedError(u'Unknown report type: xlsx',), )", '')
Here is my code:
*.py
# -*- coding: utf-8 -*-
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
# One sheet by partner
sheet = workbook.add_worksheet(report_name[:31])
bold = workbook.add_format({'bold': True})
sheet.write(0, 0, obj.name, bold)
PartnerXlsx('report.module_name.res.partner.xlsx',
'res.partner')
*.xml
<report
id="partner_xlsx"
model="res.partner"
string="Print to XLSX"
report_type="xlsx"
name="res.partner.xlsx"
file="res.partner.xlsx"
attachment_use="False"
/>