2011-10-17 12:44:33 +00:00
-
2013-02-20 07:32:36 +00:00
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 and giving the rights of Sales manager.
-
!context
uid : 'crm_res_users_salesmanager'
2012-11-30 12:51:05 +00:00
-
2013-07-16 15:10:03 +00:00
!record {model: crm.lead, id: test_crm_opp_1}:
type : 'opportunity'
name : 'Test opportunity 1'
partner_id : base.res_partner_5
2012-11-30 12:51:05 +00:00
stage_id : stage_lead1
2013-07-16 15:10:03 +00:00
description : This is the description of the test opp 1.
2012-11-30 12:51:05 +00:00
-
2013-07-16 15:10:03 +00:00
!record {model: crm.lead, id: test_crm_lead_first}:
2012-11-30 12:51:05 +00:00
type : 'lead'
2013-07-16 15:10:03 +00:00
name : 'Test lead first'
partner_id : base.res_partner_1
2012-11-30 12:51:05 +00:00
stage_id : stage_lead1
2013-07-16 15:10:03 +00:00
description : This is the description of the test lead first.
2012-11-30 15:14:13 +00:00
-
2013-07-16 15:10:03 +00:00
!record {model: crm.lead, id: test_crm_lead_second}:
type : 'lead'
name : 'Test lead second'
partner_id : base.res_partner_1
2012-11-30 15:14:13 +00:00
stage_id : stage_lead1
2013-07-16 15:10:03 +00:00
description : This is the description of the test lead second.
2012-11-30 12:51:05 +00:00
-
!python {model: crm.lead}: |
2013-07-16 15:10:03 +00:00
lead_ids = [ref('test_crm_opp_1'), ref('test_crm_lead_first'), ref('test_crm_lead_second')]
2012-11-30 12:51:05 +00:00
context.update({'active_model': 'crm.lead', 'active_ids': lead_ids, 'active_id': lead_ids[0]})
-
2012-11-30 15:14:13 +00:00
I create a merge wizard and merge the leads and opp together in the first item of the list.
2012-11-30 12:51:05 +00:00
-
!record {model: crm.merge.opportunity, id: merge_opp_wizard_01}:
-
!python {model: crm.merge.opportunity}: |
self.action_merge(cr, uid, [ref("merge_opp_wizard_01")], context=context)
-
2012-11-30 15:14:13 +00:00
I check for the resulting merged opp (based on name and partner).
2012-11-30 12:51:05 +00:00
-
!python {model: crm.lead}: |
2013-03-29 13:06:15 +00:00
merge_id = self.search(cr, uid, [('name', '=', 'Test opportunity 1'), ('partner_id','=', ref("base.res_partner_5"))])
2013-07-16 15:10:03 +00:00
2012-11-30 12:51:05 +00:00
assert merge_id, 'Fail to create merge opportunity wizard'
merge_result = self.browse(cr, uid, merge_id)[0]
2013-07-16 15:10:03 +00:00
assert merge_result.description == 'This is the description of the test opp 1.\n\nThis is the description of the test lead first.\n\nThis is the description of the test lead second.', 'Description mismatch : when merging leads/opps with different text values, these values should get concatenated and separated with line returns'
2012-11-30 15:14:13 +00:00
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
2012-11-30 12:51:05 +00:00
-
2012-11-30 15:14:13 +00:00
The other (tailing) leads/opps shouldn't exist anymore.
2012-11-30 12:51:05 +00:00
-
2012-11-30 15:14:13 +00:00
!python {model: crm.lead}: |
2013-07-16 15:10:03 +00:00
tailing_lead = self.search(cr, uid, [('id', '=', ref('test_crm_lead_first'))])
assert not tailing_lead, 'This tailing lead (id %s) should not exist anymore' % ref('test_crm_lead_second')
2012-11-30 15:14:13 +00:00
2013-07-16 15:10:03 +00:00
tailing_opp = self.search(cr, uid, [('id', '=', ref('test_crm_lead_second'))])
2012-11-30 15:14:13 +00:00
assert not tailing_opp, 'This tailing opp (id %s) should not exist anymore' % ref('test_crm_opp_01')
-
2012-11-30 15:48:50 +00:00
I want to test leads merge. Start by creating two leads (with the same partner).
2012-11-30 15:14:13 +00:00
-
!record {model: crm.lead, id: test_crm_lead_03}:
type : 'lead'
name : 'Test lead 3'
partner_id : base.res_partner_1
2012-11-30 12:51:05 +00:00
stage_id : stage_lead1
-
2012-11-30 15:14:13 +00:00
!record {model: crm.lead, id: test_crm_lead_04}:
type : 'lead'
name : 'Test lead 4'
partner_id : base.res_partner_1
2012-11-30 12:51:05 +00:00
stage_id : stage_lead1
2011-10-17 12:44:33 +00:00
-
!python {model: crm.lead}: |
2012-11-30 15:14:13 +00:00
lead_ids = [ref('test_crm_lead_03'), ref('test_crm_lead_04')]
context.update({'active_model': 'crm.lead', 'active_ids': lead_ids, 'active_id': lead_ids[0]})
2012-11-30 12:51:05 +00:00
-
2012-11-30 15:14:13 +00:00
I create a merge wizard and merge the leads together.
2012-11-30 12:51:05 +00:00
-
!record {model: crm.merge.opportunity, id: merge_opp_wizard_02}:
-
!python {model: crm.merge.opportunity}: |
self.action_merge(cr, uid, [ref("merge_opp_wizard_02")], context=context)
-
2012-11-30 15:14:13 +00:00
I check for the resulting merged lead (based on name and partner).
2012-11-30 12:51:05 +00:00
-
!python {model: crm.lead}: |
2012-11-30 15:14:13 +00:00
merge_id = self.search(cr, uid, [('name', '=', 'Test lead 3'), ('partner_id','=', ref("base.res_partner_1"))])
2012-11-30 12:51:05 +00:00
assert merge_id, 'Fail to create merge opportunity wizard'
merge_result = self.browse(cr, uid, merge_id)[0]
2012-11-30 15:14:13 +00:00
assert merge_result.partner_id.id == ref("base.res_partner_1"), 'Partner mismatch'
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
tailing_lead = self.search(cr, uid, [('id', '=', ref('test_crm_lead_04'))])
assert not tailing_lead, 'This tailing lead (id %s) should not exist anymore' % ref('test_crm_lead_04')
2012-11-30 12:51:05 +00:00
-
2012-11-30 15:48:50 +00:00
I want to test opps merge. Start by creating two opportunities (with the same partner).
2012-11-30 12:51:05 +00:00
-
2012-11-30 15:14:13 +00:00
!record {model: crm.lead, id: test_crm_opp_02}:
type : 'opportunity'
name : 'Test opportunity 2'
partner_id : base.res_partner_5
2012-11-30 12:51:05 +00:00
stage_id : stage_lead1
-
!record {model: crm.lead, id: test_crm_opp_03}:
type : 'opportunity'
name : 'Test opportunity 3'
partner_id : base.res_partner_5
stage_id : stage_lead1
-
!python {model: crm.lead}: |
2012-11-30 15:14:13 +00:00
opp_ids = [ref('test_crm_opp_02'), ref('test_crm_opp_03')]
context.update({'active_model': 'crm.lead', 'active_ids': opp_ids, 'active_id': opp_ids[0]})
2012-11-30 12:51:05 +00:00
-
2012-11-30 15:14:13 +00:00
I create a merge wizard and merge the opps together.
2011-12-06 11:45:41 +00:00
-
2012-11-30 12:51:05 +00:00
!record {model: crm.merge.opportunity, id: merge_opp_wizard_03}:
2011-12-06 11:45:41 +00:00
-
!python {model: crm.merge.opportunity}: |
2012-11-30 12:51:05 +00:00
self.action_merge(cr, uid, [ref("merge_opp_wizard_03")], context=context)
2011-12-06 11:45:41 +00:00
-
2012-11-30 12:51:05 +00:00
I check for the resulting merged opp (based on name and partner).
2011-11-02 12:51:11 +00:00
-
!python {model: crm.lead}: |
2012-11-30 15:14:13 +00:00
merge_id = self.search(cr, uid, [('name', '=', 'Test opportunity 2'), ('partner_id','=', ref("base.res_partner_5"))])
2012-11-27 16:54:01 +00:00
assert merge_id, 'Fail to create merge opportunity wizard'
merge_result = self.browse(cr, uid, merge_id)[0]
2012-11-30 15:14:13 +00:00
assert merge_result.partner_id.id == ref("base.res_partner_5"), 'Partner mismatch'
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
tailing_opp = self.search(cr, uid, [('id', '=', ref('test_crm_opp_03'))])
2013-07-16 15:10:03 +00:00
assert not tailing_opp, 'This tailing opp (id %s) should not exist anymore' % ref('test_crm_opp_03')