3 During a mixed merge (involving leads and opps), data should be handled a certain way following their type (m2o, m2m, text, ...) Start by creating two leads and an opp.
5 !record {model: crm.lead, id: test_crm_lead_01}:
8 partner_id: base.res_partner_1
10 description: This is the description of the test lead 1.
12 !record {model: crm.lead, id: test_crm_lead_02}:
15 partner_id: base.res_partner_3
17 description: This is the description of the test lead 2.
19 !record {model: crm.lead, id: test_crm_opp_01}:
21 name: 'Test opportunity 1'
22 partner_id: base.res_partner_5
24 description: This is the description of the test opp 1.
26 !python {model: crm.lead}: |
27 lead_ids = [ref('test_crm_lead_01'), ref('test_crm_lead_02'), ref('test_crm_opp_01')]
28 context.update({'active_model': 'crm.lead', 'active_ids': lead_ids, 'active_id': lead_ids[0]})
30 I create a merge wizard and merge the leads and opp together in the first item of the list.
32 !record {model: crm.merge.opportunity, id: merge_opp_wizard_01}:
34 !python {model: crm.merge.opportunity}: |
35 self.action_merge(cr, uid, [ref("merge_opp_wizard_01")], context=context)
37 I check for the resulting merged opp (based on name and partner).
39 !python {model: crm.lead}: |
40 merge_id = self.search(cr, uid, [('name', '=', 'Test opportunity 1'), ('partner_id','=', ref("base.res_partner_5"))])
41 assert merge_id, 'Fail to create merge opportunity wizard'
42 merge_result = self.browse(cr, uid, merge_id)[0]
43 assert merge_result.description == 'This is the description of the test opp 1.\n\nThis is the description of the test lead 1.\n\nThis is the description of the test lead 2.', 'Description mismatch: when merging leads/opps with different text values, these values should get concatenated and separated with line returns'
44 assert merge_result.type == 'opportunity', 'Type mismatch: when at least one opp in involved in the merge, the result should be a new opp (instead of %s)' % merge_result.type
46 The other (tailing) leads/opps shouldn't exist anymore.
48 !python {model: crm.lead}: |
49 tailing_lead = self.search(cr, uid, [('id', '=', ref('test_crm_lead_01'))])
50 assert not tailing_lead, 'This tailing lead (id %s) should not exist anymore' % ref('test_crm_lead_02')
52 tailing_opp = self.search(cr, uid, [('id', '=', ref('test_crm_lead_02'))])
53 assert not tailing_opp, 'This tailing opp (id %s) should not exist anymore' % ref('test_crm_opp_01')
55 I want to test leads merge. Start by creating two leads (with the same partner).
57 !record {model: crm.lead, id: test_crm_lead_03}:
60 partner_id: base.res_partner_1
63 !record {model: crm.lead, id: test_crm_lead_04}:
66 partner_id: base.res_partner_1
69 !python {model: crm.lead}: |
70 lead_ids = [ref('test_crm_lead_03'), ref('test_crm_lead_04')]
71 context.update({'active_model': 'crm.lead', 'active_ids': lead_ids, 'active_id': lead_ids[0]})
73 I create a merge wizard and merge the leads together.
75 !record {model: crm.merge.opportunity, id: merge_opp_wizard_02}:
77 !python {model: crm.merge.opportunity}: |
78 self.action_merge(cr, uid, [ref("merge_opp_wizard_02")], context=context)
80 I check for the resulting merged lead (based on name and partner).
82 !python {model: crm.lead}: |
83 merge_id = self.search(cr, uid, [('name', '=', 'Test lead 3'), ('partner_id','=', ref("base.res_partner_1"))])
84 assert merge_id, 'Fail to create merge opportunity wizard'
85 merge_result = self.browse(cr, uid, merge_id)[0]
86 assert merge_result.partner_id.id == ref("base.res_partner_1"), 'Partner mismatch'
87 assert merge_result.type == 'lead', 'Type mismatch: when leads get merged together, the result should be a new lead (instead of %s)' % merge_result.type
88 tailing_lead = self.search(cr, uid, [('id', '=', ref('test_crm_lead_04'))])
89 assert not tailing_lead, 'This tailing lead (id %s) should not exist anymore' % ref('test_crm_lead_04')
91 I want to test opps merge. Start by creating two opportunities (with the same partner).
93 !record {model: crm.lead, id: test_crm_opp_02}:
95 name: 'Test opportunity 2'
96 partner_id: base.res_partner_5
99 !record {model: crm.lead, id: test_crm_opp_03}:
101 name: 'Test opportunity 3'
102 partner_id: base.res_partner_5
103 stage_id: stage_lead1
105 !python {model: crm.lead}: |
106 opp_ids = [ref('test_crm_opp_02'), ref('test_crm_opp_03')]
107 context.update({'active_model': 'crm.lead', 'active_ids': opp_ids, 'active_id': opp_ids[0]})
109 I create a merge wizard and merge the opps together.
111 !record {model: crm.merge.opportunity, id: merge_opp_wizard_03}:
113 !python {model: crm.merge.opportunity}: |
114 self.action_merge(cr, uid, [ref("merge_opp_wizard_03")], context=context)
116 I check for the resulting merged opp (based on name and partner).
118 !python {model: crm.lead}: |
119 merge_id = self.search(cr, uid, [('name', '=', 'Test opportunity 2'), ('partner_id','=', ref("base.res_partner_5"))])
120 assert merge_id, 'Fail to create merge opportunity wizard'
121 merge_result = self.browse(cr, uid, merge_id)[0]
122 assert merge_result.partner_id.id == ref("base.res_partner_5"), 'Partner mismatch'
123 assert merge_result.type == 'opportunity', 'Type mismatch: when opps get merged together, the result should be a new opp (instead of %s)' % merge_result.type
124 tailing_opp = self.search(cr, uid, [('id', '=', ref('test_crm_opp_03'))])
125 assert not tailing_opp, 'This tailing opp (id %s) should not exist anymore' % ref('test_crm_opp_03')