mirror of
https://github.com/bringout/oca-ocb-crm.git
synced 2026-04-22 11:12:02 +02:00
19.0 vanilla
This commit is contained in:
parent
dc68f80d3f
commit
7221b9ac46
610 changed files with 135477 additions and 161677 deletions
|
|
@ -21,6 +21,13 @@ class TestLeadAssignPerf(TestLeadAssignCommon):
|
|||
of random in tests.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
# patch registry to simulate a ready environment
|
||||
self.patch(self.env.registry, 'ready', True)
|
||||
# we don't use mock_mail_gateway thus want to mock smtp to test the stack
|
||||
self._mock_smtplib_connection()
|
||||
|
||||
@mute_logger('odoo.models.unlink', 'odoo.addons.crm.models.crm_team', 'odoo.addons.crm.models.crm_team_member')
|
||||
def test_assign_perf_duplicates(self):
|
||||
""" Test assign process with duplicates on partner. Allow to ensure notably
|
||||
|
|
@ -47,11 +54,11 @@ class TestLeadAssignPerf(TestLeadAssignCommon):
|
|||
# commit probability and related fields
|
||||
leads.flush_recordset()
|
||||
|
||||
# randomness: at least 1 query
|
||||
# randomness: at least 1 query, +3 for demo -> 957 + 5
|
||||
with self.with_user('user_sales_manager'):
|
||||
self.env['res.users'].has_group('base.group_user') # warmup the cache to avoid inconsistency between community an enterprise
|
||||
with self.assertQueryCount(user_sales_manager=1266): # crm 1187
|
||||
self.env['crm.team'].browse(self.sales_teams.ids)._action_assign_leads(work_days=2)
|
||||
self.env.user._is_internal() # warmup the cache to avoid inconsistency between community an enterprise
|
||||
with self.assertQueryCount(user_sales_manager=962):
|
||||
self.env['crm.team'].browse(self.sales_teams.ids)._action_assign_leads()
|
||||
|
||||
# teams assign
|
||||
leads = self.env['crm.lead'].search([('id', 'in', leads.ids)]) # ensure order
|
||||
|
|
@ -62,12 +69,12 @@ class TestLeadAssignPerf(TestLeadAssignCommon):
|
|||
self.assertEqual(len(leads_st1) + len(leads_stc), len(leads)) # Make sure all lead are assigned
|
||||
|
||||
# salespersons assign
|
||||
self.members.invalidate_model(['lead_month_count'])
|
||||
self.assertMemberAssign(self.sales_team_1_m1, 11) # 45 max on 2 days (3) + compensation (8.4)
|
||||
self.assertMemberAssign(self.sales_team_1_m2, 4) # 15 max on 2 days (1) + compensation (2.8)
|
||||
self.assertMemberAssign(self.sales_team_1_m3, 4) # 15 max on 2 days (1) + compensation (2.8)
|
||||
self.assertMemberAssign(self.sales_team_convert_m1, 8) # 30 max on 15 (2) + compensation (5.6)
|
||||
self.assertMemberAssign(self.sales_team_convert_m2, 15) # 60 max on 15 (4) + compsantion (11.2)
|
||||
self.members.invalidate_model(['lead_month_count', 'lead_day_count'])
|
||||
self.assertMemberAssign(self.sales_team_1_m1, 2) # 45 max on one month -> 2 daily
|
||||
self.assertMemberAssign(self.sales_team_1_m2, 1) # 15 max on one month -> 1 daily
|
||||
self.assertMemberAssign(self.sales_team_1_m3, 1) # 15 max on one month -> 1 daily
|
||||
self.assertMemberAssign(self.sales_team_convert_m1, 1) # 30 max on one month -> 1 daily
|
||||
self.assertMemberAssign(self.sales_team_convert_m2, 2) # 60 max on one month -> 2 daily
|
||||
|
||||
@mute_logger('odoo.models.unlink', 'odoo.addons.crm.models.crm_team', 'odoo.addons.crm.models.crm_team_member')
|
||||
def test_assign_perf_no_duplicates(self):
|
||||
|
|
@ -93,10 +100,10 @@ class TestLeadAssignPerf(TestLeadAssignCommon):
|
|||
# commit probability and related fields
|
||||
leads.flush_recordset()
|
||||
|
||||
# randomness: at least 1 query
|
||||
# randomness: at least 1 query, +1 for demo
|
||||
with self.with_user('user_sales_manager'):
|
||||
with self.assertQueryCount(user_sales_manager=585): # crm 584
|
||||
self.env['crm.team'].browse(self.sales_teams.ids)._action_assign_leads(work_days=2)
|
||||
with self.assertQueryCount(user_sales_manager=552):
|
||||
self.env['crm.team'].browse(self.sales_teams.ids)._action_assign_leads()
|
||||
|
||||
# teams assign
|
||||
leads = self.env['crm.lead'].search([('id', 'in', leads.ids)]) # ensure order
|
||||
|
|
@ -105,12 +112,12 @@ class TestLeadAssignPerf(TestLeadAssignCommon):
|
|||
self.assertEqual(len(leads_st1) + len(leads_stc), 100)
|
||||
|
||||
# salespersons assign
|
||||
self.members.invalidate_model(['lead_month_count'])
|
||||
self.assertMemberAssign(self.sales_team_1_m1, 11) # 45 max on 2 days (3) + compensation (8.4)
|
||||
self.assertMemberAssign(self.sales_team_1_m2, 4) # 15 max on 2 days (1) + compensation (2.8)
|
||||
self.assertMemberAssign(self.sales_team_1_m3, 4) # 15 max on 2 days (1) + compensation (2.8)
|
||||
self.assertMemberAssign(self.sales_team_convert_m1, 8) # 30 max on 15 (2) + compensation (5.6)
|
||||
self.assertMemberAssign(self.sales_team_convert_m2, 15) # 60 max on 15 (4) + compensation (11.2)
|
||||
self.members.invalidate_model(['lead_month_count', 'lead_day_count'])
|
||||
self.assertMemberAssign(self.sales_team_1_m1, 2) # 45 max on one month -> 2 daily
|
||||
self.assertMemberAssign(self.sales_team_1_m2, 1) # 15 max on one month -> 1 daily
|
||||
self.assertMemberAssign(self.sales_team_1_m3, 1) # 15 max on one month -> 1 daily
|
||||
self.assertMemberAssign(self.sales_team_convert_m1, 1) # 30 max on one month -> 1 daily
|
||||
self.assertMemberAssign(self.sales_team_convert_m2, 2) # 60 max on one month -> 2 daily
|
||||
|
||||
@mute_logger('odoo.models.unlink', 'odoo.addons.crm.models.crm_team', 'odoo.addons.crm.models.crm_team_member')
|
||||
def test_assign_perf_populated(self):
|
||||
|
|
@ -176,10 +183,10 @@ class TestLeadAssignPerf(TestLeadAssignCommon):
|
|||
# commit probability and related fields
|
||||
leads.flush_recordset()
|
||||
|
||||
# randomness
|
||||
# randomness: add 2 queries
|
||||
with self.with_user('user_sales_manager'):
|
||||
with self.assertQueryCount(user_sales_manager=6280): # crm 6226 / com 6276 / ent 6278
|
||||
self.env['crm.team'].browse(sales_teams.ids)._action_assign_leads(work_days=30)
|
||||
with self.assertQueryCount(user_sales_manager=5173):
|
||||
self.env['crm.team'].browse(sales_teams.ids)._action_assign_leads()
|
||||
|
||||
# teams assign
|
||||
leads = self.env['crm.lead'].search([('id', 'in', leads.ids)])
|
||||
|
|
@ -187,12 +194,12 @@ class TestLeadAssignPerf(TestLeadAssignCommon):
|
|||
self.assertEqual(leads.user_id, sales_teams.member_ids)
|
||||
|
||||
# salespersons assign
|
||||
self.members.invalidate_model(['lead_month_count'])
|
||||
self.assertMemberAssign(self.sales_team_1_m1, 45) # 45 max on one month
|
||||
self.assertMemberAssign(self.sales_team_1_m2, 15) # 15 max on one month
|
||||
self.assertMemberAssign(self.sales_team_1_m3, 15) # 15 max on one month
|
||||
self.assertMemberAssign(self.sales_team_convert_m1, 30) # 30 max on one month
|
||||
self.assertMemberAssign(self.sales_team_convert_m2, 60) # 60 max on one month
|
||||
self.assertMemberAssign(sales_team_3_m1, 60) # 60 max on one month
|
||||
self.assertMemberAssign(sales_team_3_m2, 60) # 60 max on one month
|
||||
self.assertMemberAssign(sales_team_3_m3, 15) # 15 max on one month
|
||||
self.members.invalidate_model(['lead_month_count', 'lead_day_count'])
|
||||
self.assertMemberAssign(self.sales_team_1_m1, 2) # 45 max on one month -> 2 daily
|
||||
self.assertMemberAssign(self.sales_team_1_m2, 1) # 15 max on one month -> 1 daily
|
||||
self.assertMemberAssign(self.sales_team_1_m3, 1) # 15 max on one month -> 1 daily
|
||||
self.assertMemberAssign(self.sales_team_convert_m1, 1) # 30 max on one month -> 1 daily
|
||||
self.assertMemberAssign(self.sales_team_convert_m2, 2) # 60 max on one month -> 2 daily
|
||||
self.assertMemberAssign(sales_team_3_m1, 2) # 60 max on one month -> 2 daily
|
||||
self.assertMemberAssign(sales_team_3_m2, 2) # 60 max on one month -> 2 daily
|
||||
self.assertMemberAssign(sales_team_3_m3, 1) # 15 max on one month -> 1 daily
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue