Thursday, August 13, 2026
1 change · 17.0
Enhancements to existing features
General Ledger Excel exports now group accounts into smarter batches instead of processing each account separately. This reduces export time for companies with large accounting datasets while keeping memory usage under control.
Original PR description
### Description of the issue/feature this PR addresses: This PR optimizes the XLSX export process for large accounting reports by implementing a "smarter" batching strategy. Three months ago, a…
### Description of the issue/feature this PR addresses: This PR optimizes the XLSX export process for large accounting reports by implementing a "smarter" batching strategy. Three months ago, a batching mechanism was introduced to prevent memory errors during large exports. However, that implementation batched every single account individually. While this solved the memory consumption issue, it introduced a significant performance regression: processing thousands of tiny batches one-by-one is extremely slow due to the overhead of repeated report engine calls. This change introduces a weighted batching system that groups multiple accounts together into a single batch until a maximum line threshold is reached. This strikes an ideal balance between low memory usage and high execution speed. ### Current behavior before PR: The system uses _get_accounts_with_move_lines to retrieve a list of accounts. The export logic iterates through every account individually, creating a separate batch for each one. For reports with many accounts (even those with few moves), the overhead of calling the report engine for every single account causes the export to take an excessive amount of time. Memory usage is low, but time performance is poor. ### Desired behavior after PR is merged: The new _get_account_ids_and_weights_with_move_lines method fetches both the account IDs and the count of moves (weight) associated with them in a single SQL query. The _build_account_batches method packs accounts sequentially into batches of up to 500,000 lines. Small accounts are grouped together. Large "mega-accounts" that exceed the limit are isolated into their own batches to prevent memory spikes. _get_accounts_with_move_lines is deprecated. It is effectively superseded by the more informative weighted query, providing the data necessary for the smarter partition logic. ### Benchmarks | # Move Lines | Before | After | | --- |---|---| | ~5.6million | Times Out | 32sec | | ~3.5million| Times Out | 11sec | ### References #103329 opw-6077972 opw-5723374 opw-5950806 opw-5915227 opw-6066290 opw-5914983 --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr