Skip to Content
Menu
This question has been flagged
1 Reply
5563 Views

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"
  />
Avatar
Discard
Best Answer

1.Make sure you added "report_xlsx" in the dependency

2. Check the indentation 

        PartnerXlsx('report.module_name.res.partner.xlsx',

        'res.partner')

        should be outside the class.

3. <report

      id="partner_xlsx"

      model="res.partner"

      string="Print to XLSX"

      report_type="xlsx"

      name="your_module_name.res.partner.xlsx"

      file="your_module_name.res.partner.xlsx"

      attachment_use="False"

Avatar
Discard
Related Posts Replies Views Activity
0
Dec 22
3494
2
Dec 24
5084
0
Jan 19
3675
1
Dec 18
1820
1
Jan 18
4529