2 In order to test the changes on stage of a lead or an opportunity with OpenERP,
3 I create some leads and test the stage changes.
5 I want to change the probability to 0.0 when the opportunity is marked as lost.
6 So I set its Change probability automatically true.
8 !record {model: crm.case.stage, id: crm.stage_lead6}:
13 - crm.section_sales_department
16 I create a lead 'Test Lead1'.
18 !record {model: crm.lead, id: crm_lead_openerppresentation0}:
19 categ_id: crm.categ_oppor4
25 section_id: crm.section_sales_department
29 !python {model: crm.lead}: |
30 self.case_open(cr, uid, [ref('crm_lead_openerppresentation0')])
34 !python {model: crm.lead}: |
35 self.onchange_stage_id(cr, uid, [ref('crm_lead_openerppresentation0')], [], context)
39 !python {model: crm.lead}: |
40 self.stage_find_percent(cr, uid, 10.0, [])
42 I find that this lead can be converted to opportunity.
44 !record {model: crm.lead2opportunity.partner, id: crm_lead2opportunity_partner0}:
48 So I convert the lead to opportunity.
50 !python {model: crm.lead2opportunity.partner}: |
51 self.action_apply(cr, uid, [ref('crm_lead2opportunity_partner0')], context={'active_ids': [ref('crm_lead_openerppresentation0')]})
53 I check that lead is now converted to opportunity.
55 !python {model: crm.lead}: |
56 lead = self.browse(cr, uid, ref('crm_lead_openerppresentation0'))
57 assert lead.type == 'opportunity', 'Lead is not converted to opportunity!'
59 I mark this opportunity as lost.
61 !python {model: crm.lead}: |
62 self.case_mark_lost(cr, uid, [ref('crm_lead_openerppresentation0')])
64 I check whether the probability is set according to stage change or not.
66 !python {model: crm.lead}: |
67 opportunity = self.browse(cr, uid, ref('crm_lead_openerppresentation0'))
68 assert opportunity.stage_id.id == ref('crm.stage_lead6'), 'Stage is not changed!'
69 assert opportunity.probability == 0.0, 'Probability is wrong!'
71 I create one more opportunity.
73 !record {model: crm.lead, id: crm_lead_test2}:
76 categ_id: crm.categ_oppor3
77 planned_revenue: 50000.0
79 section_id: crm.section_sales_department
81 I open this opportunity.
83 !python {model: crm.lead}: |
84 self.case_open(cr, uid, [ref('crm_lead_test2')])
86 I mark this opportunity as won.
88 !python {model: crm.lead}: |
89 self.case_mark_won(cr, uid, [ref('crm_lead_test2')])
91 I check whether the stage is changed to 'Won' and probability is 100.0 or not.
93 !python {model: crm.lead}: |
94 opportunity = self.browse(cr, uid, ref('crm_lead_test2'))
95 assert opportunity.stage_id.id == ref('crm.stage_lead5'), 'Stage is not changed!'
96 assert opportunity.probability == 100.0, 'Probability is wrong!'