Improve the statments
[odoo/odoo.git] / addons / crm / test / test_crm_stage_changes.yml
1 -
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.
4 -
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.
7 -
8   !record {model: crm.case.stage, id: crm.stage_lead6}:
9     name: Lost
10     on_change: true
11     probability: 0.0
12     section_ids:
13       - crm.section_sales_department
14     sequence: 0
15 -
16   I create a lead 'Test Lead1'.
17 -
18   !record {model: crm.lead, id: crm_lead_openerppresentation0}:
19     categ_id: crm.categ_oppor4
20     day_close: 0.0
21     day_open: 0.0
22     name: Test Lead1
23     planned_revenue: 0.0
24     probability: 10.0
25     section_id: crm.section_sales_department
26 -
27   I open the lead.
28 -
29   !python {model: crm.lead}: |
30     self.case_open(cr, uid, [ref('crm_lead_openerppresentation0')])
31 -
32   I assigning stage.
33 -
34   !python {model: crm.lead}: |
35     self.onchange_stage_id(cr, uid, [ref('crm_lead_openerppresentation0')], [], context)
36 -
37   I assigning percent.
38 -
39   !python {model: crm.lead}: |
40     self.stage_find_percent(cr, uid, 10.0, [])
41 -
42   I find that this lead can be converted to opportunity.
43 -
44   !record {model: crm.lead2opportunity.partner, id: crm_lead2opportunity_partner0}:
45     action: 'create'
46     name: 'convert'
47 -
48   So I convert the lead to opportunity.
49 -
50   !python {model: crm.lead2opportunity.partner}: |
51     self.action_apply(cr, uid, [ref('crm_lead2opportunity_partner0')], context={'active_ids': [ref('crm_lead_openerppresentation0')]})
52 -
53   I check that lead is now converted to opportunity.
54 -
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!'
58 -
59   I mark this opportunity as lost.
60 -
61   !python {model: crm.lead}: |
62     self.case_mark_lost(cr, uid, [ref('crm_lead_openerppresentation0')])
63 -
64   I check whether the probability is set according to stage change or not.
65 -
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!'
70 -
71   I create one more opportunity.
72 -
73   !record {model: crm.lead, id: crm_lead_test2}:
74     name: Partner Demo
75     type: opportunity
76     categ_id: crm.categ_oppor3
77     planned_revenue: 50000.0
78     probability: 100.0
79     section_id: crm.section_sales_department
80 -
81   I open this opportunity.
82 -
83   !python {model: crm.lead}: |
84     self.case_open(cr, uid, [ref('crm_lead_test2')])
85 -
86   I mark this opportunity as won.
87 -
88   !python {model: crm.lead}: |
89     self.case_mark_won(cr, uid, [ref('crm_lead_test2')])
90 -
91   I check whether the stage is changed to 'Won' and probability is 100.0 or not.
92 -
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!'