Skip to content
Browse files

[FIX] account: add performance test

The test is split to ease forward-port.

opw 2121587

Co-authored by: François Honoré <>

closes #41053

Signed-off-by: Nans Lefebvre (len) <>
  • Loading branch information
len-odoo committed Nov 26, 2019
1 parent 5db13a3 commit 7f0c8155f48492ff79c07af06cdf4196ff7587a3
Showing with 80 additions and 0 deletions.
  1. +1 −0 addons/account/tests/
  2. +79 −0 addons/account/tests/
@@ -22,3 +22,4 @@
from . import test_account_fiscal_year
from . import test_account_all_l10n
from . import test_reconciliation_matching_rules
from . import test_reconciliation_heavy_load
@@ -0,0 +1,79 @@
from odoo import api, fields
from odoo.tests import tagged
from odoo.addons.account.tests.account_test_classes import AccountingTestCase

@tagged('post_install', '-at_install')
class TestReconciliationHeavyLoad(AccountingTestCase):
"""Check that reconciliation can be done for a move with many lines

def _create_move(self, journal):
values = {
'ref': "Test reconcile - Auto-generated by script",
'state': 'draft',
return journal.env['account.move'].create(values)

def _get_values_account_move_line(
self, account, journal, name, move,
credit=0, debit=0,
return {
'name': name,
'quantity': 1,
'credit': credit,
'debit': debit,
'date': date,

def setUp(self):
super(TestReconciliationHeavyLoad, self).setUp()

self.account_type = self.env.ref('account.data_account_type_receivable')

self.journal = self.env['account.journal'].search([
('type', '=', 'bank'),
('company_id', '=',,
], limit=1)

self.account = self.env['account.account'].search([
('user_type_id', '=',,
('company_id', '=',,
], limit=1)

def test_heavy_load_reconciliation(self):
"""Does reconciliation on a move with nb_lines lines.
To avoid burdening uselessly the runbot, we only set nb_lines to 10,
but it should be of order 10^3 to be meaningful.
The day we manage to use system build settings to execute tests
this could be done automatically for "heavy load builds",
but for now this should be changed manually.

total = 0
line_ids = []
amount_per_line = 1
nb_lines = 10 # change this to 1000 or more
move = self._create_move(self.journal)

for i in range(nb_lines):
name = "Move line credit #%s" % i
total += amount_per_line
values = self._get_values_account_move_line(
self.account, self.journal, name, move, credit=amount_per_line)
line_ids.append((0, False, values))

values = self._get_values_account_move_line(
self.account, self.journal, "Move line Debit", move, debit=total)
line_ids.append((0, False, values))

move.write({'line_ids': line_ids})



0 comments on commit 7f0c815

Please sign in to comment.
You can’t perform that action at this time.