From a3db3dcd09e9776872a93f9f04a8d5f8e41a56e9 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Fri, 21 Oct 2011 15:34:43 +0530 Subject: [PATCH] [IMP] Improved mass_leads2opportunity.yml, merge_opportunity.yml, lead2opportunity2win.yml, partner2opportunity.yml bzr revid: ron@tinyerp.com-20111021100443-my6035x3fem8gc34 --- addons/crm/__openerp__.py | 2 +- addons/crm/res_partner.py | 2 +- .../crm/test/process/lead2opportunity2win.yml | 42 +++++++++++ .../process/lead2opportunity_win_lost.yml | 70 ------------------- .../test/process/mass_leads2opportunity.yml | 14 +--- addons/crm/test/process/merge_opportunity.yml | 19 ++--- .../crm/test/process/partner2opportunity.yml | 15 +--- 7 files changed, 55 insertions(+), 109 deletions(-) create mode 100644 addons/crm/test/process/lead2opportunity2win.yml delete mode 100644 addons/crm/test/process/lead2opportunity_win_lost.yml diff --git a/addons/crm/__openerp__.py b/addons/crm/__openerp__.py index fb2aa8679d4..04c57637dbe 100644 --- a/addons/crm/__openerp__.py +++ b/addons/crm/__openerp__.py @@ -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', diff --git a/addons/crm/res_partner.py b/addons/crm/res_partner.py index f5c841111fe..0fc6f5dff89 100644 --- a/addons/crm/res_partner.py +++ b/addons/crm/res_partner.py @@ -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')]) diff --git a/addons/crm/test/process/lead2opportunity2win.yml b/addons/crm/test/process/lead2opportunity2win.yml new file mode 100644 index 00000000000..3565ea96d46 --- /dev/null +++ b/addons/crm/test/process/lead2opportunity2win.yml @@ -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' diff --git a/addons/crm/test/process/lead2opportunity_win_lost.yml b/addons/crm/test/process/lead2opportunity_win_lost.yml deleted file mode 100644 index eacb919c3eb..00000000000 --- a/addons/crm/test/process/lead2opportunity_win_lost.yml +++ /dev/null @@ -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!' diff --git a/addons/crm/test/process/mass_leads2opportunity.yml b/addons/crm/test/process/mass_leads2opportunity.yml index 4286eac1848..21b7d0a6120 100644 --- a/addons/crm/test/process/mass_leads2opportunity.yml +++ b/addons/crm/test/process/mass_leads2opportunity.yml @@ -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. - diff --git a/addons/crm/test/process/merge_opportunity.yml b/addons/crm/test/process/merge_opportunity.yml index 2028c304276..7f3cccbff0d 100644 --- a/addons/crm/test/process/merge_opportunity.yml +++ b/addons/crm/test/process/merge_opportunity.yml @@ -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}) diff --git a/addons/crm/test/process/partner2opportunity.yml b/addons/crm/test/process/partner2opportunity.yml index 542056f0f9b..b9668a1a0f9 100644 --- a/addons/crm/test/process/partner2opportunity.yml +++ b/addons/crm/test/process/partner2opportunity.yml @@ -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!'