[IMP] Improved mass_leads2opportunity.yml, merge_opportunity.yml, lead2opportunity2win.yml, partner2opportunity.yml

bzr revid: ron@tinyerp.com-20111021100443-my6035x3fem8gc34
This commit is contained in:
ron@tinyerp.com 2011-10-21 15:34:43 +05:30
parent c6a71b8dbb
commit a3db3dcd09
7 changed files with 55 additions and 109 deletions

View File

@ -120,7 +120,7 @@ Creates a dashboard for CRM that includes:
],
'test': [
'test/process/draft2open_lead.yml',
'test/process/lead2opportunity_win_lost.yml',
'test/process/lead2opportunity2win.yml',
'test/process/merge_opportunity.yml',
'test/process/partner2opportunity.yml',
'test/process/cancel_lead.yml',

View File

@ -34,7 +34,7 @@ class res_partner(osv.osv):
'Phonecalls'),
}
def make_opportunity(self, cr, uid, ids, opportunity, planned_revenue=0.0, probability=0.0, partner_id=None. context=None):
def make_opportunity(self, cr, uid, ids, opportunity, planned_revenue=0.0, probability=0.0, partner_id=None, context=None):
categ = self.pool.get('crm.case.categ')
address = self.address_get(cr, uid, ids)
categ_ids = categ.search(cr, uid, [('object_id.model','=','crm.lead')])

View File

@ -0,0 +1,42 @@
-
Convert opportunity based on exiting partner.
-
!python {model: crm.lead}: |
self.convert_opportunity(cr, uid ,[ref("crm_case_qrecorp0")], ref("base.res_partner_agrolait"))
-
After converted in opportunity, i test that lead is converted to opportunity.
-
!python {model: crm.lead}: |
lead = self.browse(cr, uid, ref('crm_case_qrecorp0'))
assert lead.type == 'opportunity', 'Lead is not converted to opportunity!'
assert lead.partner_id.id == ref("base.res_partner_agrolait"), 'Partner missmatch!'
assert lead.stage_id.id == ref("stage_lead1"), 'Stage of opportunity is incorrect!'
-
Finally, i won this opportunity, so i close this opportunity.
-
!python {model: crm.lead}: |
self.case_mark_won(cr, uid, [ref("crm_case_qrecorp0")])
-
After wininng the opportunity , I test the opportunity.
-
!python {model: crm.lead}: |
lead = self.browse(cr, uid, ref('crm_case_qrecorp0'))
assert lead.state == 'done', 'Opportunity is not in done state!'
assert lead.stage_id.name == 'Won', ' Stage of Opportunity is not win!'
assert lead.probability == 100.0, 'probability revenue should not be 100.0!'
-
I add internal note to this opportunity, so i create note.
-
!record {model: crm.add.note, id: crm_add_note_won_opportunity}:
body: 'I won this Opportunity'
-
Apply this note to opportunity.
-
!python {model: crm.add.note}: |
self.action_add(cr, uid, [ref("crm_add_note_won_opportunity")], {"active_model": "crm.lead","active_ids": [ref("crm_case_qrecorp0")]})
-
I test Internal latest note added on opportunity .
-
- !python {model: crm.lead}: |
- lead = self.browse(cr, uid, ref('crm_case_qrecorp0'))
- assert lead.message_ids[0].subject == 'I won this Opportunity', 'Fail to Added interal note on opportunity'

View File

@ -1,70 +0,0 @@
-
I test to convert lead to real business opportunity, so first i create existing partner attached with lead.
-
!record {model: crm.lead2opportunity.partner, id: crm_lead2opportunity_partner_create_1}:
action: 'exist'
partner_id: base.res_partner_agrolait
-
Create opportunity based on exiting partner.
-
!python {model: crm.lead2opportunity.partner}: |
self.action_apply(cr, uid, [ref("crm_lead2opportunity_partner_create_1")], {'active_ids': [ref("crm_case_qrecorp0")], 'active_id': ref("crm_case_qrecorp0")})
-
After converted in opportunity, i test to lead is converted to opportunity.
-
!python {model: crm.lead}: |
lead = self.browse(cr, uid, ref('crm_case_qrecorp0'))
assert lead.type == 'opportunity', 'Lead is not converted to opportunity!'
assert lead.partner_id.id == ref("base.res_partner_agrolait"), 'Partner missmatch!'
assert lead.stage_id.id == ref("stage_lead1"), 'Stage of opportunity is incorrect!'
-
Finally, i won this opportunity, so i close this opportunity.
-
!python {model: crm.lead}: |
self.case_mark_won(cr, uid, [ref("crm_case_qrecorp0")])
-
I check opportunity is close or not.
-
!assert {model: crm.lead, id: crm.crm_case_qrecorp0, string: Opportunity in done state}:
- state == "done"
-
In order to test stage of opportunity after win, i will test stage of opportunity.
-
!assert {model: crm.lead, id: crm.crm_case_qrecorp0, string: stage of opportunity is win}:
- stage_id.name == "Won"
-
I add internal note to this opportunity, so i create note.
-
!record {model: crm.add.note, id: crm_add_note_won_opportunity}:
body: 'I won this Opportunity'
-
Apply this note to opportunity.
-
!python {model: crm.add.note}: |
self.action_add(cr, uid, [ref("crm_add_note_won_opportunity")], {"active_model": "crm.lead","active_ids": [ref("crm_case_qrecorp0")]})
# TODO: cheked For ordering of history of message
#-
# I test Internal latest note added on opportunity .
#-
# !python {model: crm.lead}: |
# lead = self.browse(cr, uid, ref('crm_case_qrecorp0'))
# assert lead.message_ids[0].subject == 'I won this Opportunity', 'Fail to Added interal note on opportunity'
-
After winning the opportunity, i test probability is 100.
-
!assert {model: crm.lead, id: crm.crm_case_qrecorp0, string: Probability is equal to 100}:
- probability == 100.0
-
Suppose i have opportinity in initial stage, i will check after loss my `opportunity` , probability of that opportunity is 0
-
!python {model: crm.lead}: |
self.case_open(cr, uid, [ref("crm_case_rdroundfundingunits0")])
self.case_mark_lost(cr, uid, [ref("crm_case_rdroundfundingunits0")])
-
I check after loss the opportunity, probability set to 0.0 and lost stage set accordingly.
-
!python {model: crm.lead}: |
opportunity = self.browse(cr, uid, ref('crm_case_rdroundfundingunits0'))
assert opportunity.stage_id.id == ref('crm.stage_lead6'), 'Stage is not changed!'
assert opportunity.probability == 0.0, 'Probability is wrong!'

View File

@ -1,16 +1,8 @@
-
Using mass wizard convert two lead to opportunity ,so first i create mass record for
converting in opportunity.
Convert two Leads to two opportunity(Mass conversion).
-
!record {model: crm.lead2opportunity.partner.mass, id: crm_lead2opportunity_partner_mass0}:
user_ids:
- base.user_root
section_id: crm.section_sales_department
-
Convert mass Leads to opportunity.
-
!python {model: crm.lead2opportunity.partner.mass}: |
self.mass_convert(cr, uid, [ref("crm_lead2opportunity_partner_mass0")],{'active_ids': [ref("crm_case_employee0"), ref("crm_case_electonicgoodsdealer0")], 'active_id': ref("crm_case_qrecorp0")})
!python {model: crm.lead}: |
self.convert_opportunity(cr, uid, [ref("crm_case_employee0"), ref("crm_case_electonicgoodsdealer0")], mass_convert=True)
-
First lead converted on opportunity.i test it.
-

View File

@ -1,17 +1,8 @@
-
I have two opportunity ,so i merge this two Opportunities.
-
!python {model: crm.merge.opportunity}: |
op_ids=self.pool.get('crm.lead').browse(cr, uid, [ref('crm_case_bankwealthy2'), ref('crm_case_unifliege')])
self.merge(cr, uid, op_ids)
-
I test which two opportunity has been merged .
I have two opportunity ,so i merge this two Opportunities, I test which two opportunity has been merged .
-
!python {model: crm.lead}: |
lead = self.browse(cr, uid, ref('crm_case_bankwealthy2'))
merge = 'Merged opportunities' in lead.message_ids[0].subject
assert merge,'Fail to create Merge opportunity'
assert lead.type == 'opportunity', 'Merged opportunity type not change!'
assert lead.partner_id.id == ref("base.res_partner_accent"), 'Partner missmatch!'
assert lead.stage_id.id == ref("stage_lead2"), 'Stage of probability is incorrect!'
op_list = [ref('crm_case_bankwealthy2'),ref('crm_case_unifliege')]
op_ids=self.pool.get('crm.lead').browse(cr,uid,op_list)
lead_ids = [ref('crm_case_qrecorp0')]
self.merge_opportunity(cr, uid, op_ids, {'lead_ids': lead_ids})

View File

@ -1,17 +1,8 @@
- |
I will create opportunity by partner.
-
!record {model: crm.partner2opportunity, id: crm_partner2opportunity_id_0}:
name: BalmerInc S.A.
planned_revenue: 200.0
partner_id: base.res_partner_9
probability: 150.0
Convert partner to opportunity, i test to convert opportunity is from partner.
-
Convert partner to opportunity, i will test to convert opportunity is correct.
-
!python {model: crm.partner2opportunity}: |
opportunity = self.make_opportunity(cr, uid, [ref("crm_partner2opportunity_id_0")])
!python {model: res.partner}: |
opportunity = self.make_opportunity(cr, uid, [ref("base.res_partner_9")], 'BalmerInc S.A.', 200.0, 150.0)
opportunity_rec = self.pool.get('crm.lead').browse(cr, uid, opportunity['res_id'])
assert opportunity_rec.type == 'opportunity', 'Lead is not converted to opportunity!'
assert opportunity_rec.planned_revenue == 200.0, 'Planned revenue should be 200!'