Merge lp:~openerp-dev/openobject-addons/6.1-opw-581240-cbi into lp:openobject-addons/6.1

Proposed by Chris Biersbach (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/6.1-opw-581240-cbi
Merge into: lp:openobject-addons/6.1
Diff against target: 19 lines (+8/-1)
1 file modified
account/ (+8/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.1-opw-581240-cbi
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email:

Description of the change

The issue: When trying to generate accounting reports, an error is thrown because the sql query parser stack overflows

The reason: There are too many accounts, thus when getting all of the children, the query becomes too long

The fix: I split the accounts into chunks of a predetermined size and do one query per chunk, causing the stack to no longer overflow

To post a comment you must log in.

Unmerged revisions

7077. By Chris Biersbach (OpenERP)

[FIX] When too many accounts need to be printed in reports, the sql query parser runs into a stack overflow. This splits the account ids into multiple chunks/queries to make sure this does not happen anymore.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/'
2--- account/ 2012-10-09 09:58:14 +0000
3+++ account/ 2012-12-07 10:12:24 +0000
4@@ -250,7 +250,14 @@
6 def _get_children_and_consol(self, cr, uid, ids, context=None):
7 #this function search for all the children and all consolidated children (recursively) of the given account ids
8- ids2 =, uid, [('parent_id', 'child_of', ids)], context=context)
9+ # we split the ids into several chunks, because if there are too many at once, this can cause the sql query parser stack to overflow
10+ if not isinstance(ids, (list, tuple)):
11+ ids = [ids]
12+ chunk_size = 100
13+ ids_split = [ids[i:i + chunk_size] for i in range(0, len(ids), chunk_size)]
14+ ids2 = []
15+ for chunk in ids_split:
16+ ids2.extend(, uid, [('parent_id', 'child_of', chunk)], context=context))
17 ids3 = []
18 for rec in self.browse(cr, uid, ids2, context=context):
19 for child in rec.child_consol_ids: