Skip to content
Snippets Groups Projects
Commit 28410d8e authored by Hoang Tran's avatar Hoang Tran
Browse files

[IMP] account: avoid fetching debit, credit in aged partner balance


Perform fetching, using `read` or `_read_from_database` on matched debit
and credit takes a huge amount of time, if there are too many acml being
processed. Delay fetching to `mapped` improve the performance greatly.

closes odoo/odoo#75969

Signed-off-by: default avatarQuentin De Paoli (qdp) <qdp@openerp.com>
parent 1d115930
No related branches found
No related tags found
No related merge requests found
......@@ -128,9 +128,9 @@ class ReportAgedPartnerBalance(models.AbstractModel):
# which look up the cache to determine the records to read, and has
# quadratic complexity when the number of records is large...
move_lines = self.env['account.move.line'].browse(aml_ids)
move_lines.read(['partner_id', 'company_id', 'balance', 'matched_debit_ids', 'matched_credit_ids'])
move_lines.mapped('matched_debit_ids').read(['max_date', 'company_id', 'amount'])
move_lines.mapped('matched_credit_ids').read(['max_date', 'company_id', 'amount'])
move_lines._read_from_database(['partner_id', 'company_id', 'balance'])
move_lines.mapped('matched_debit_ids')._read_from_database(['max_date', 'company_id', 'amount'])
move_lines.mapped('matched_credit_ids')._read_from_database(['max_date', 'company_id', 'amount'])
for line in move_lines:
partner_id = line.partner_id.id or False
if partner_id not in partners_amount:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment