[FIX]crm: crm merge tests testing new merge behaviour (opps before leads)

bzr revid: dle@openerp.com-20130329130615-gbjqw0x2ybeekext
This commit is contained in:
dle@openerp.com 2013-03-29 14:06:15 +01:00
parent 58a31f00d8
commit 2d925d5c27
2 changed files with 5 additions and 7 deletions

View File

@ -632,8 +632,7 @@ class crm_lead(base_stage, format_address, osv.osv):
sequence = -1
if opportunity.stage_id and opportunity.stage_id.state != 'cancel':
sequence = opportunity.stage_id.sequence
create_time_reverse = - time.mktime(datetime.strptime(opportunity.create_date, tools.DEFAULT_SERVER_DATETIME_FORMAT).timetuple())
sequenced_opps.append(((int(opportunity.type == 'opportunity'), sequence, create_time_reverse), opportunity))
sequenced_opps.append(((int(opportunity.type == 'opportunity'), sequence, -opportunity.id), opportunity))
sequenced_opps.sort(reverse=True)
opportunities = map(itemgetter(1), sequenced_opps)

View File

@ -37,20 +37,19 @@
I check for the resulting merged opp (based on name and partner).
-
!python {model: crm.lead}: |
merge_id = self.search(cr, uid, [('name', '=', 'Test lead 1'), ('partner_id','=', ref("base.res_partner_1"))])
merge_id = self.search(cr, uid, [('name', '=', 'Test opportunity 1'), ('partner_id','=', ref("base.res_partner_5"))])
assert merge_id, 'Fail to create merge opportunity wizard'
merge_result = self.browse(cr, uid, merge_id)[0]
assert merge_result.partner_id.id == ref("base.res_partner_1"), 'Partner mismatch: when merging leads/opps with different m2o values, the first not null value prevails (the other are dropped)'
assert merge_result.description == 'This is the description of the test lead 1.\n\nThis is the description of the test lead 2.\n\nThis is the description of the test opp 1.', 'Description mismatch: when merging leads/opps with different text values, these values should get concatenated and separated with line returns'
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'
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
-
The other (tailing) leads/opps shouldn't exist anymore.
-
!python {model: crm.lead}: |
tailing_lead = self.search(cr, uid, [('id', '=', ref('test_crm_lead_02'))])
tailing_lead = self.search(cr, uid, [('id', '=', ref('test_crm_lead_01'))])
assert not tailing_lead, 'This tailing lead (id %s) should not exist anymore' % ref('test_crm_lead_02')
tailing_opp = self.search(cr, uid, [('id', '=', ref('test_crm_opp_01'))])
tailing_opp = self.search(cr, uid, [('id', '=', ref('test_crm_lead_02'))])
assert not tailing_opp, 'This tailing opp (id %s) should not exist anymore' % ref('test_crm_opp_01')
-
I want to test leads merge. Start by creating two leads (with the same partner).