[FIX] delivery: propagate additional fields in chained pickings
[odoo/odoo.git] / addons / crm / test / lead2opportunity_assign_salesmen.yml
1 -
2   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).
3 -
4   !record {model: crm.lead, id: test_crm_lead_01}:
5     type: 'lead'
6     name: 'Test lead 1'
7     email_from: 'Raoul Grosbedon <raoul@grosbedon.fr>'
8     stage_id: stage_lead1
9 -
10   !record {model: crm.lead, id: test_crm_lead_02}:
11     type: 'lead'
12     name: 'Test lead 2'
13     email_from: 'Raoul Grosbedon <raoul@grosbedon.fr>'
14     stage_id: stage_lead1
15 -
16   !record {model: crm.lead, id: test_crm_lead_03}:
17     type: 'lead'
18     name: 'Test lead 3'
19     email_from: 'Raoul Grosbedon <raoul@grosbedon.fr>'
20     stage_id: stage_lead1
21 -
22   !record {model: crm.lead, id: test_crm_lead_04}:
23     type: 'lead'
24     name: 'Test lead 4'
25     contact_name: 'Fabrice Lepoilu'
26     stage_id: stage_lead1
27 -
28   !record {model: crm.lead, id: test_crm_lead_05}:
29     type: 'lead'
30     name: 'Test lead 5'
31     contact_name: 'Fabrice Lepoilu'
32     stage_id: stage_lead1
33 -
34   !record {model: crm.lead, id: test_crm_lead_06}:
35     type: 'lead'
36     name: 'Test lead 6'
37     partner_name: 'Agrolait SuperSeed SA'
38     stage_id: stage_lead1
39 -
40   !record {model: res.users, id: test_res_user_01}:
41     name: 'Test user A'
42     login: 'tua'
43     new_password: 'tua'
44 -
45   !record {model: res.users, id: test_res_user_02}:
46     name: 'Test user B'
47     login: 'tub'
48     new_password: 'tub'
49 -
50   !record {model: res.users, id: test_res_user_03}:
51     name: 'Test user C'
52     login: 'tuc'
53     new_password: 'tuc'
54 -
55   !record {model: res.users, id: test_res_user_04}:
56     name: 'Test user D'
57     login: 'tud'
58     new_password: 'tud'
59 -
60   I create a mass convert wizard and convert all the leads.
61 -
62   !python {model: crm.lead2opportunity.partner.mass}: |
63     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")})
64     id = self.create(cr, uid, {'user_ids': [(6, 0, [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)
65     self.mass_convert(cr, uid, [id], context=context)
66 -
67   The leads should now be opps with a salesman and a salesteam.  Also, salesmen should have been assigned following a round-robin method.
68 -
69   !python {model: crm.lead}: |
70     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)
71     salesmen_ids = [ref('test_res_user_01'), ref('test_res_user_02'), ref('test_res_user_03'), ref('test_res_user_04')]
72     i = 0
73     for opp in opps:
74       assert opp.type == 'opportunity', 'Type mismatch: this should be an opp, not a lead'
75       assert opp.user_id.id == salesmen_ids[i], 'Salesman mismatch: expected salesman %r, got %r' % (salesmen_ids[i], opp.user_id.id)
76       i = i+1 if (i < len(salesmen_ids) - 1) else 0