Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvement for OCA accounting reports #219

Merged
merged 1 commit into from
Sep 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this dependency here? It should be in other module

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pedrobaeza

I have added the cStringIO and xlsxwriter dependencies because I have override the create_xlslx_report method for "Customization of xlsxwriter options to limit usage of memory for xlsx files generation".

See lines 38 to 51 of this file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then the previous PR was incorrect. We can't mix XLSX generation with PDF generation. That should be optional through a module account_financial_report_qweb_xlsx

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pedrobaeza , you're right on this point.
But it's not the subject of this PR.
I will try to do another PR for that, but I don't know when I could do that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks

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