diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index d420bd93f37..332390ff2df 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -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) diff --git a/addons/crm/test/crm_lead_merge.yml b/addons/crm/test/crm_lead_merge.yml index c50af5214e6..b14f9272df9 100644 --- a/addons/crm/test/crm_lead_merge.yml +++ b/addons/crm/test/crm_lead_merge.yml @@ -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).