[IMP] improve crm_partner_assing demo file
[odoo/odoo.git] / addons / crm / test / lead2opportunity2win.yml
1 -
2   Giving access rights of salesman to convert the lead into opportunity.
3 -
4   !context
5     uid: 'crm_res_users_salesman'
6 -
7   In order to test the conversion of a lead into a opportunity,
8 -
9   I set lead to open stage.
10 -
11    !python {model: crm.lead}: |
12      self.write(cr, uid, [ref("crm_case_3")],{'stage_id':ref("stage_lead1")})
13 -
14   I check if the lead stage is "Open".
15 -
16   !assert {model: crm.lead, id: crm.crm_case_3, string: Lead stage is Open}:
17      - stage_id.sequence == 1
18 -
19   I convert lead into opportunity for exiting customer.
20 -
21   !python {model: crm.lead}: |
22     self.convert_opportunity(cr, uid ,[ref("crm_case_3")], ref("base.res_partner_2"))
23 -
24   I check details of converted opportunity.
25 -
26   !python {model: crm.lead}: |
27     lead = self.browse(cr, uid, ref('crm_case_3'))
28     assert lead.type == 'opportunity', 'Lead is not converted to opportunity!'
29     assert lead.partner_id.id == ref("base.res_partner_2"), 'Partner mismatch!'
30     assert lead.stage_id.id == ref("stage_lead1"), 'Stage of opportunity is incorrect!'
31 -
32   Now I begin communication and schedule a phone call with the customer.
33 -
34   !python {model: crm.phonecall2phonecall}: |
35     import time
36     context.update({'active_model': 'crm.lead', 'active_ids': [ref('crm_case_3')],'active_id': ref('crm_case_3')})
37     call_id = self.create(cr, uid, {'date': time.strftime('%Y-%m-%d %H:%M:%S'),
38                 'name': "Bonjour M. Jean, Comment allez-vous? J'ai bien reçu votre demande, pourrions-nous en parler quelques minutes?"}, context=context)
39     self.action_schedule(cr, uid, [call_id], context=context)
40 -
41   Now I schedule meeting with customer.
42 -
43   !python {model: crm.lead}: |
44     self.action_schedule_meeting(cr, uid, [ref('crm_case_3')])
45 -
46   After communicated  with customer, I put some notes with contract details.
47 -
48   !python {model: crm.lead}: |
49     self.message_post(cr, uid, [ref('crm_case_3')], subject='Test note', body='Détails envoyés par le client sur ​​le FAX pour la qualité')
50 -
51   I win this opportunity
52 -
53   !python {model: crm.lead}: |
54     self.case_mark_won(cr, uid, [ref("crm_case_3")])
55 -
56   I check details of the opportunity after having won the opportunity.
57 -
58   !python {model: crm.lead}: |
59     lead = self.browse(cr, uid, ref('crm_case_3'))
60     assert lead.stage_id.id == ref('crm.stage_lead6'), "Opportunity stage should be 'Won'."
61     assert lead.stage_id.probability == 100.0, "Opportunity is not 'done'"
62     assert lead.probability == 100.0, "Revenue probability should be 100.0!"
63 -
64   I convert mass lead into opportunity customer.
65 -
66   !python {model: crm.lead2opportunity.partner.mass}: |
67     context.update({'active_model': 'crm.lead', 'active_ids': [ref("crm_case_13"), ref("crm_case_2")], 'active_id': ref("crm_case_13")})
68     id = self.create(cr, uid, {'user_ids': [(6, 0, [ref('base.user_root')])], 'section_id': ref('crm.section_sales_department')}, context=context)
69     self.mass_convert(cr, uid, [id], context=context)
70 -
71   Now I check first lead converted on opportunity.
72 -
73   !python {model: crm.lead}: |
74     opp = self.browse(cr, uid, ref('crm_case_13'))
75     assert opp.name == "Plan to buy 60 keyboards and mouses", "Opportunity name not correct"
76     assert opp.type == 'opportunity', 'Lead is not converted to opportunity!'
77     expected_partner = "Will McEncroe"
78     assert opp.partner_id.name == expected_partner, 'Partner mismatch! %s vs %s' % (opp.partner_id.name, expected_partner)
79     assert opp.stage_id.id == ref("stage_lead1"), 'Stage of probability is incorrect!'
80 -
81   Then check for second lead converted on opportunity.
82 -
83   !python {model: crm.lead}: |
84     opp = self.browse(cr, uid, ref('crm_case_2'))
85     assert opp.name == "Interest in Your New Software", "Opportunity name not correct"
86     assert opp.type == 'opportunity', 'Lead is not converted to opportunity!'
87     assert opp.stage_id.id == ref("stage_lead1"), 'Stage of probability is incorrect!'
88 -
89   I loose the second opportunity
90 -
91   !python {model: crm.lead}: |
92     self.case_mark_lost(cr, uid, [ref("crm_case_2")])
93 -
94   I check details of the opportunity after the loose
95 -
96   !python {model: crm.lead}: |
97     lead = self.browse(cr, uid, ref('crm_case_2'))
98     assert lead.stage_id.id == ref('crm.stage_lead7'), "Opportunity stage should be 'Lost'."
99     assert lead.stage_id.sequence != 1 and lead.stage_id.probability == 0.0, "Lost opportunity is not in 'cancel' state!"
100     assert lead.probability == 0.0, "Revenue probability should be 0.0!"
101 -
102   I confirm review needs meeting.
103 -
104   !python {model: calendar.event}: |
105     context.update({'active_model': 'calendar.event'})
106     self.write(cr, uid, [ref('calendar.calendar_event_4')], {'state': 'open'})
107 -
108   I invite a user for meeting.
109 -
110   !python {model: calendar.attendee}: |
111     meeting_id = self.create(cr, uid, {'partner_id': ref('base.partner_root'), 'email': 'user@meeting.com' })
112     self.do_accept(cr, uid, [meeting_id])