Browse Source

[IMP] report_xlsx - Pass the report instance as well as ids of records to print to the 'create_xlsx_report' method + Instanciate the parser and make it available for the 'generate_xlsx_report' method

pull/171/head
sebalix 8 years ago
committed by Enric Tobella
parent
commit
ff0d718c18
No known key found for this signature in database GPG Key ID: 1A2546A1B7BA2451
  1. 2
      report_xlsx/README.rst
  2. 10
      report_xlsx/report/report_xlsx.py

2
report_xlsx/README.rst

@ -74,4 +74,4 @@ This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.
To contribute to this module, please visit https://odoo-community.org.

10
report_xlsx/report/report_xlsx.py

@ -24,11 +24,15 @@ class ReportXlsx(report_sxw):
if report.ids:
self.title = report.name
if report.report_type == 'xlsx':
objs = self.env[self.table].browse(ids)
return self.create_xlsx_report(data, objs)
return self.create_xlsx_report(ids, data, report)
return super(ReportXlsx, self).create(cr, uid, ids, data, context)
def create_xlsx_report(self, data, objs):
def create_xlsx_report(self, ids, data, report):
self.parser_instance = self.parser(
self.env.cr, self.env.uid, self.name2, self.env.context)
objs = self.getObjects(
self.env.cr, self.env.uid, ids, self.env.context)
self.parser_instance.set_context(objs, data, objs.ids, 'xlsx')
file_data = StringIO()
workbook = xlsxwriter.Workbook(file_data)
self.generate_xlsx_report(workbook, data, objs)

Loading…
Cancel
Save