summaryrefslogtreecommitdiff
path: root/addons/crm/tests
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2020-06-22 14:26:31 +0000
committerThibault Delavallée <tde@odoo.com>2020-10-06 14:48:10 +0000
commit973a2998666813ca4fbe90f1b486c1b18091c4e7 (patch)
tree1c5b1cb9c1f3a9d53e8f952a16afa1dfe2da7730 /addons/crm/tests
parent950dd491bc4b680e0bcfab83815313e909a3c282 (diff)
[IMP] crm: improve handle_salesmen_assignment performances
Handle salesmen allows to assign responsible to leads using a round robin like algorithm. Currently a write on each lead is done to update its team and responsible, even if number of leads is far greater than number of available users to assign. Current implementation can be simplified by doing one write per sales person to assign on its batch of leads, or a single write if no salesmen has to be assigned. Performance counter on a mass convert wizard on 50 leads show that we gain about 9% of queries (125 on 1471) with this simple optimization. Task ID-2351604 PR #59084 closes odoo/odoo#59100 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/crm/tests')
-rw-r--r--addons/crm/tests/test_crm_lead_convert_mass.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/addons/crm/tests/test_crm_lead_convert_mass.py b/addons/crm/tests/test_crm_lead_convert_mass.py
index 05c347301a6..d24de28b39e 100644
--- a/addons/crm/tests/test_crm_lead_convert_mass.py
+++ b/addons/crm/tests/test_crm_lead_convert_mass.py
@@ -24,7 +24,7 @@ class TestLeadConvertMass(crm_common.TestLeadConvertMassCommon):
with self.assertQueryCount(user_sales_manager=0):
test_leads = self.env['crm.lead'].browse(test_leads.ids)
- with self.assertQueryCount(user_sales_manager=330):
+ with self.assertQueryCount(user_sales_manager=252):
test_leads.handle_salesmen_assignment(user_ids=user_ids, team_id=False)
self.assertEqual(test_leads.team_id, self.sales_team_convert | self.sales_team_1)
@@ -42,7 +42,7 @@ class TestLeadConvertMass(crm_common.TestLeadConvertMassCommon):
with self.assertQueryCount(user_sales_manager=0):
test_leads = self.env['crm.lead'].browse(test_leads.ids)
- with self.assertQueryCount(user_sales_manager=342):
+ with self.assertQueryCount(user_sales_manager=217):
test_leads.handle_salesmen_assignment(user_ids=user_ids, team_id=team_id)
self.assertEqual(test_leads.team_id, self.sales_team_convert)
@@ -166,7 +166,7 @@ class TestLeadConvertMass(crm_common.TestLeadConvertMassCommon):
test_leads = self._create_leads_batch(count=50, user_ids=[False])
user_ids = self.assign_users.ids
- with self.assertQueryCount(user_sales_manager=1472):
+ with self.assertQueryCount(user_sales_manager=1347):
mass_convert = self.env['crm.lead2opportunity.partner.mass'].with_context({
'active_model': 'crm.lead',
'active_ids': test_leads.ids,