[IMP] introduce tests for the salesmen assignations
authorAntonin Bourguignon <abo@openerp.com>
Fri, 30 Nov 2012 17:00:34 +0000 (18:00 +0100)
committerAntonin Bourguignon <abo@openerp.com>
Fri, 30 Nov 2012 17:00:34 +0000 (18:00 +0100)
bzr revid: abo@openerp.com-20121130170034-7f5ytzptsks997oq

addons/crm/__openerp__.py
addons/crm/test/process/lead2opportunity_assign_salesmen.yml [new file with mode: 0644]

index d80d951..76f65cc 100644 (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',
diff --git a/addons/crm/test/process/lead2opportunity_assign_salesmen.yml b/addons/crm/test/process/lead2opportunity_assign_salesmen.yml
new file mode 100644 (file)
index 0000000..9487736
--- /dev/null
@@ -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
\ No newline at end of file