[FIX] delivery: propagate additional fields in chained pickings
[odoo/odoo.git] / addons / crm / test / crm_lead_merge.yml
1
2 -
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.
4 -
5   !record {model: crm.lead, id: test_crm_lead_01}:
6     type: 'lead'
7     name: 'Test lead 1'
8     partner_id: base.res_partner_1
9     stage_id: stage_lead1
10     description: This is the description of the test lead 1.
11 -
12   !record {model: crm.lead, id: test_crm_lead_02}:
13     type: 'lead'
14     name: 'Test lead 2'
15     partner_id: base.res_partner_3
16     stage_id: stage_lead1
17     description: This is the description of the test lead 2.
18 -
19   !record {model: crm.lead, id: test_crm_opp_01}:
20     type: 'opportunity'
21     name: 'Test opportunity 1'
22     partner_id: base.res_partner_5
23     stage_id: stage_lead1
24     description: This is the description of the test opp 1.
25 -
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]})
29 -
30   I create a merge wizard and merge the leads and opp together in the first item of the list.
31 -
32   !record {model: crm.merge.opportunity, id: merge_opp_wizard_01}:
33 -
34   !python {model: crm.merge.opportunity}: |
35     self.action_merge(cr, uid, [ref("merge_opp_wizard_01")], context=context)
36 -
37   I check for the resulting merged opp (based on name and partner).
38 -
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
45 -
46   The other (tailing) leads/opps shouldn't exist anymore.
47 -
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')
51
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')
54 -
55   I want to test leads merge.  Start by creating two leads (with the same partner).
56 -
57   !record {model: crm.lead, id: test_crm_lead_03}:
58     type: 'lead'
59     name: 'Test lead 3'
60     partner_id: base.res_partner_1
61     stage_id: stage_lead1
62 -
63   !record {model: crm.lead, id: test_crm_lead_04}:
64     type: 'lead'
65     name: 'Test lead 4'
66     partner_id: base.res_partner_1
67     stage_id: stage_lead1
68 -
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]})
72 -
73   I create a merge wizard and merge the leads together.
74 -
75   !record {model: crm.merge.opportunity, id: merge_opp_wizard_02}:
76 -
77   !python {model: crm.merge.opportunity}: |
78     self.action_merge(cr, uid, [ref("merge_opp_wizard_02")], context=context)
79 -
80   I check for the resulting merged lead (based on name and partner).
81 -
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')
90 -
91   I want to test opps merge.  Start by creating two opportunities (with the same partner).
92 -
93   !record {model: crm.lead, id: test_crm_opp_02}:
94     type: 'opportunity'
95     name: 'Test opportunity 2'
96     partner_id: base.res_partner_5
97     stage_id: stage_lead1
98 -
99   !record {model: crm.lead, id: test_crm_opp_03}:
100     type: 'opportunity'
101     name: 'Test opportunity 3'
102     partner_id: base.res_partner_5
103     stage_id: stage_lead1
104 -
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]})
108 -
109   I create a merge wizard and merge the opps together.
110 -
111   !record {model: crm.merge.opportunity, id: merge_opp_wizard_03}:
112 -
113   !python {model: crm.merge.opportunity}: |
114     self.action_merge(cr, uid, [ref("merge_opp_wizard_03")], context=context)
115 -
116   I check for the resulting merged opp (based on name and partner).
117 -
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')