[MERGE] mail/chatter complete review/refactoring
[odoo/odoo.git] / addons / crm / test / process / lead2opportunity2win.yml
1 -
2   In order to test convert customer lead into opportunity, 
3 -
4   I open customer lead.
5 -
6    !python {model: crm.lead}: |
7      self.case_open(cr, uid, [ref("crm_case_4")])
8
9   I check lead state is "Open". 
10 -
11   !assert {model: crm.lead, id: crm.crm_case_4, string: Lead in open state}:
12      - state == "open"
13 -
14   I create partner from lead. 
15 -
16   !record {model: crm.lead2partner, id: crm_lead2partner_id1, context: '{"active_model": "crm.lead", "active_ids": [ref("crm_case_4")]}'}:
17 -
18    !python {model: crm.lead2partner}: |
19      context.update({'active_model': 'crm.lead', 'active_ids': [ref('crm_case_4')], 'active_id': ref('crm_case_4')})
20      self.make_partner(cr, uid ,[ref("crm_lead2partner_id1")], context=context)
21 -
22   I convert lead into opportunity for exiting customer.
23 -
24   !python {model: crm.lead}: |
25     self.convert_opportunity(cr, uid ,[ref("crm_case_4")], ref("base.res_partner_2"))
26 -
27   I check details of converted opportunity. 
28 -
29   !python {model: crm.lead}: |
30     lead = self.browse(cr, uid, ref('crm_case_4'))
31     assert lead.type == 'opportunity', 'Lead is not converted to opportunity!'
32     assert lead.partner_id.id == ref("base.res_partner_2"), 'Partner mismatch!'
33     assert lead.stage_id.id == ref("stage_lead1"), 'Stage of opportunity is incorrect!'
34 -
35   Now I begin communication and schedule a phone call with the customer.
36 -
37   !python {model: crm.opportunity2phonecall}: |
38     import time
39     context.update({'active_model': 'crm.lead', 'active_ids': [ref('crm_case_4')]})
40     call_id = self.create(cr, uid, {'date': time.strftime('%Y-%m-%d %H:%M:%S'), 
41                 'name': "Bonjour M. Jean, Comment êtes-vous? J'ai obtenu votre demande. peut-on parler au sujet de ce pour quelques minutes?"}, context=context)
42     self.action_schedule(cr, uid, [call_id], context=context)
43 -
44   I check that phonecall is scheduled for that opportunity.
45 -
46   !python {model: crm.phonecall}: |
47     ids = self.search(cr, uid, [('opportunity_id', '=', ref('crm_case_4'))])
48     assert len(ids), 'phonecall is not scheduled'
49 -
50   Now I schedule meeting with customer.
51 -
52   !python {model: crm.lead}: |
53     self.action_makeMeeting(cr, uid, [ref('crm_case_4')])
54 -
55   After communicated  with customer, I put some notes with contract details.
56 -
57   !python {model: crm.lead}: |
58     self.message_post(cr, uid, [ref('crm_case_4')], subject='Test note', body='ces détails envoyés par le client sur ​​le FAX pour la qualité')
59 -
60   I win this opportunity
61 -
62   !python {model: crm.lead}: |
63     self.case_mark_won(cr, uid, [ref("crm_case_4")])
64 -
65   I check details of the opportunity after having won the opportunity.
66 -
67   !python {model: crm.lead}: |
68     lead = self.browse(cr, uid, ref('crm_case_4'))
69     assert lead.stage_id.id == ref('crm.stage_lead6'), "Opportunity stage should be 'Won'."
70     assert lead.state == 'done', "Opportunity is not in 'done' state!"
71     assert lead.probability == 100.0, "Revenue probability should be 100.0!"
72 -
73   I convert mass lead into opportunity customer.
74 -
75   !python {model: crm.lead2opportunity.partner.mass}: |
76     context.update({'active_model': 'crm.lead', 'active_ids': [ref("crm_case_11"), ref("crm_case_2")], 'active_id': ref("crm_case_11")}) 
77     id = self.create(cr, uid, {'user_ids': [ref('base.user_root')], 'section_id': ref('crm.section_sales_department')}, context=context)
78     self.mass_convert(cr, uid, [id], context=context)
79 -
80   Now I check first lead converted on opportunity.
81 -
82   !python {model: crm.lead}: |
83     opp = self.browse(cr, uid, ref('crm_case_11'))
84     assert opp.name == "Need estimated cost for new project", "Opportunity name not correct"
85     assert opp.type == 'opportunity', 'Lead is not converted to opportunity!'
86     expected_partner = "Thomas Passot"
87     assert opp.partner_id.name == expected_partner, 'Partner mismatch! %s vs %s' % (opp.partner_id.name, expected_partner)
88     assert opp.stage_id.id == ref("stage_lead1"), 'Stage of probability is incorrect!'
89 -
90   Then check for second lead converted on opportunity.
91 -
92   !python {model: crm.lead}: |
93     opp = self.browse(cr, uid, ref('crm_case_2'))
94     assert opp.name == "Interest in Your New Software", "Opportunity name not correct"
95     assert opp.type == 'opportunity', 'Lead is not converted to opportunity!'
96     assert opp.stage_id.id == ref("stage_lead1"), 'Stage of probability is incorrect!'
97 -
98   I loose the second opportunity
99 -
100   !python {model: crm.lead}: |
101     self.case_mark_lost(cr, uid, [ref("crm_case_2")])
102 -
103   I check details of the opportunity after the loose
104 -
105   !python {model: crm.lead}: |
106     lead = self.browse(cr, uid, ref('crm_case_2'))
107     assert lead.stage_id.id == ref('crm.stage_lead8'), "Opportunity stage should be 'Lost'."
108     assert lead.state == 'cancel', "Lost opportunity is not in 'cancel' state!"
109     assert lead.probability == 0.0, "Revenue probability should be 0.0!"
110 -
111   I confirm review needs meeting.
112 -
113   !python {model: crm.meeting}: |
114     context.update({'active_model': 'crm.meeting'}) 
115     self.case_open(cr, uid, [ref('base_calendar.crm_meeting_4')])
116 -
117   I invite a user for meeting.
118 -
119   !python {model: calendar.attendee}: |
120     meeting_id = self.create(cr, uid, {'user_id': ref('base.user_root'), 'email': 'user@meeting.com' })
121     self.do_accept(cr, uid, [meeting_id])