Skip to content

Commit

Permalink
Merge pull request #219 from jcoux/oca_reports_optimization
Browse files Browse the repository at this point in the history
Performance improvement for OCA accounting reports
  • Loading branch information
fclementic2c authored Sep 9, 2016
2 parents f9d637d + 9ad59f8 commit 13d4310
Show file tree
Hide file tree
Showing 4 changed files with 358 additions and 99 deletions.
17 changes: 17 additions & 0 deletions account_financial_report_qweb/report/abstract_report_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from cStringIO import StringIO
import xlsxwriter
from openerp.addons.report_xlsx.report.report_xlsx import ReportXlsx


Expand Down Expand Up @@ -33,6 +35,21 @@ def __init__(self, name, table, rml=False, parser=False, header=True,
self.format_amount = None
self.format_percent_bold_italic = None

def create_xlsx_report(self, ids, data, report):
""" Overrides method to add constant_memory option used for large files
"""
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, ids, 'xlsx')
file_data = StringIO()
workbook = xlsxwriter.Workbook(file_data, {'constant_memory': True})
self.generate_xlsx_report(workbook, data, objs)
workbook.close()
file_data.seek(0)
return (file_data.read(), 'xlsx')

def generate_xlsx_report(self, workbook, data, objects):
report = objects

Expand Down
Loading

0 comments on commit 13d4310

Please sign in to comment.