[IMP] crm_lead yml tests.
[odoo/odoo.git] / addons / crm / test / process / merge_opportunity.yml
1 -
2   I make direct opportunity for customer.
3 -
4   !python {model: crm.partner2opportunity}: |
5     context.update({'active_model': 'res.partner', 'active_ids': [ref("base.res_partner_9")]})
6     res_id = self.create(cr, uid, {'name': "enquête pour l'achat de services"}, context=context)
7     self.make_opportunity(cr, uid, [res_id], context=context)
8 -
9   I make another opportunity from phonecall for same customer.
10 -
11   !python {model: crm.phonecall2opportunity}: |
12     context.update({'active_model': 'crm.phonecall', 'active_ids': [ref("crm.crm_case_phone06")]})
13     res_id = self.create(cr, uid, {'name': "Quoi de prix de votre autre service?", 'partner_id': ref("base.res_partner_9")}, context=context)
14     self.make_opportunity(cr, uid, [res_id], context=context)
15 -
16   Now I merge all opportunities of customer.
17 -
18   !python {model: crm.lead}: |
19     opportunity_ids = self.search(cr, uid, [('partner_id','=', ref("base.res_partner_9"))])
20     context.update({'active_model': 'crm.lead', 'active_ids': opportunity_ids, 'active_id': opportunity_ids[0]})
21 -
22   !record {model: crm.merge.opportunity, id: opportunity_merge_id }:
23 -
24   !python {model: crm.merge.opportunity}: |
25     self.action_merge(cr, uid, [ref("opportunity_merge_id")], context=context)
26 -
27   I check for merged opportunities for customer. 
28 -
29   !python {model: crm.lead}: |
30     merge_id = self.search(cr, uid, [('partner_id','=', ref("base.res_partner_9"))])
31     assert merge_id, 'Fail to create Merge opportunity'
32     merge_data = self.browse(cr, uid, merge_id)[0]
33     assert merge_data.type == 'opportunity', 'Merged opportunity type not change!'
34     assert merge_data.partner_id.id == ref("base.res_partner_9"), 'Partner missmatch!'
35 -
36   Now I schedule another phonecall to customer after merged.
37 -
38   !python {model: crm.phonecall2phonecall}: |
39     context.update({'active_model': 'crm.phonecall', 'active_ids': [ref("crm.crm_case_phone06")], 'active_id': ref("crm.crm_case_phone06")})
40     res_id = self.create(cr, uid, {'name': "vos chances sont fusionnés en un seul"}, context=context)
41     self.action_schedule(cr, uid, [res_id], context=context)
42
43   I schedule meeting on this phonecall.
44 -
45   !python {model: crm.phonecall}: |
46     self.action_make_meeting(cr, uid, [ref("crm.crm_case_phone06")])
47 -
48   I set phone call to not held.
49 -
50   !python {model: crm.phonecall}: |
51     self.case_pending(cr, uid, [ref("crm.crm_case_phone06")])
52 -
53   I check that the phone call is in 'Not Held' state. 
54 -
55   !assert {model: crm.phonecall, id: crm.crm_case_phone06, string: Phone call held.}:
56     - state == "pending"
57 -
58   I cancelled the phone call. 
59 -
60   !python {model: crm.phonecall}: |
61     self.case_cancel(cr, uid, [ref("crm.crm_case_phone06")])
62 -
63   I check that the phone call is in 'Cancelled' state.
64 -
65   !assert {model: crm.phonecall, id: crm.crm_case_phone06, string: Phone call is not cancelled.}:
66     - state == "cancel"
67 -
68   I reset the phone call. 
69 -
70   !python {model: crm.phonecall}: |
71     self.case_reset(cr, uid, [ref("crm.crm_case_phone06")])
72 -
73   I check that the phone call is reset or not.
74 -
75   !assert {model: crm.phonecall, id: crm.crm_case_phone06, string: Phone call is not reset.}:
76     - state == "open"
77 -
78   I set phone call to held (done).
79 -
80   !python {model: crm.phonecall}: |
81     self.case_close(cr, uid, [ref("crm.crm_case_phone06")])
82 -
83   I check that the phone call is in 'Held' state.
84 -
85   !assert {model: crm.phonecall, id: crm.crm_case_phone06, string: Phone call is not held.}:
86     - state == "done"