[IMP] introduce tests for the salesmen assignations

bzr revid: abo@openerp.com-20121130170034-7f5ytzptsks997oq
This commit is contained in:
Antonin Bourguignon 2012-11-30 18:00:34 +01:00
parent a9f67c3729
commit a38bdc15c5
2 changed files with 71 additions and 0 deletions

View File

@ -105,6 +105,7 @@ Dashboard for CRM will include:
'test': [
'test/process/communication_with_customer.yml',
'test/process/lead2opportunity2win.yml',
'test/process/lead2opportunity_assign_salesmen.yml',
'test/process/merge_opportunity.yml',
'test/process/cancel_lead.yml',
'test/process/action_rule.yml',

View File

@ -0,0 +1,70 @@
-
During a lead to opp conversion, salesmen should be assigned to leads following the round-robin method. Start by creating 6 leads (1 to 6) and 4 salesmen (A to D).
-
!record {model: crm.lead, id: test_crm_lead_01}:
type: 'lead'
name: 'Test lead 1'
stage_id: stage_lead1
-
!record {model: crm.lead, id: test_crm_lead_02}:
type: 'lead'
name: 'Test lead 2'
stage_id: stage_lead1
-
!record {model: crm.lead, id: test_crm_lead_03}:
type: 'lead'
name: 'Test lead 3'
stage_id: stage_lead1
-
!record {model: crm.lead, id: test_crm_lead_04}:
type: 'lead'
name: 'Test lead 4'
stage_id: stage_lead1
-
!record {model: crm.lead, id: test_crm_lead_05}:
type: 'lead'
name: 'Test lead 5'
stage_id: stage_lead1
-
!record {model: crm.lead, id: test_crm_lead_06}:
type: 'lead'
name: 'Test lead 6'
stage_id: stage_lead1
-
!record {model: res.users, id: test_res_user_01}:
name: 'Test user A'
login: 'tua'
new_password: 'tua'
-
!record {model: res.users, id: test_res_user_02}:
name: 'Test user B'
login: 'tub'
new_password: 'tub'
-
!record {model: res.users, id: test_res_user_03}:
name: 'Test user C'
login: 'tuc'
new_password: 'tuc'
-
!record {model: res.users, id: test_res_user_04}:
name: 'Test user D'
login: 'tud'
new_password: 'tud'
-
I create a mass convert wizard and convert all the leads.
-
!python {model: crm.lead2opportunity.partner.mass}: |
context.update({'active_model': 'crm.lead', 'active_ids': [ref("test_crm_lead_01"), ref("test_crm_lead_02"), ref("test_crm_lead_03"), ref("test_crm_lead_04"), ref("test_crm_lead_05"), ref("test_crm_lead_06")], 'active_id': ref("test_crm_lead_01")})
id = self.create(cr, uid, {'user_ids': [ref('test_res_user_01'), ref('test_res_user_02'), ref('test_res_user_03'), ref('test_res_user_04')], 'section_id': ref('crm.section_sales_department')}, context=context)
self.mass_convert(cr, uid, [id], context=context)
-
The leads should now be opps with a salesman and a salesteam. Also, salesmen should have been assigned following a round-robin method.
-
!python {model: crm.lead}: |
opps = self.browse(cr, uid, [ref("test_crm_lead_01"), ref("test_crm_lead_02"), ref("test_crm_lead_03"), ref("test_crm_lead_04"), ref("test_crm_lead_05"), ref("test_crm_lead_06")], context)
salesmen_ids = [ref('test_res_user_01'), ref('test_res_user_02'), ref('test_res_user_03'), ref('test_res_user_04')]
i = 0
for opp in opps:
assert opp.type == 'opportunity', 'Type mismatch: this should be an opp, not a lead'
assert opp.user_id == salesmen_ids[i], 'Salesman mismatch: expected salesman %s, got %s' % (salesmen_ids[i], opp.user_id)
i = i+1 if (i < len(salesmen_ids) - 1) else 0