[IMP]crm : Improve the test cases
[odoo/odoo.git] / addons / crm / test / test_crm_lead_case2.yml
1 -
2    In order to do complete test the CRM in OpenERP,
3    I will create new full configured record and carry test on it.
4 -  |
5    I Start by creating "Demo Sales Team" with No Unlink.
6    Creating a crm.case.section record
7 -
8   !record {model: crm.case.section, id: crm_case_section_demosalesteam}:
9     code: DEMO
10     complete_name: Demo Sales Team
11     name: Demo Sales Team
12     allow_unlink: False
13     member_ids:
14       - base.user_admin
15     stage_ids:
16       - crm.stage_lead1
17       - crm.stage_lead2
18       - crm.stage_lead3
19       - crm.stage_lead4
20       - crm.stage_lead5
21       - crm.stage_lead6
22     working_hours: 0.0
23     resource_calendar_id: resource.timesheet_group1
24     parent_id: crm.section_sales_department
25 -
26    I assign segmentation.
27 -
28    !record {model: res.users, id: res_users_usercrm0}:
29      context_section_id: crm_case_section_demosalesteam    
30 -  |
31    Creating a new lead "Demo Customer" and I provide an address to this
32    demo customer and email "info@democustomer.com" and Also "Demo Sales Team".
33 -
34    !record {model: crm.lead, id: crm_lead_democustomer}:
35      email_from: info@democustomer.com
36      name: Demo Customer
37      partner_name: NotSoTinySARL
38      phone: (+32).81.81.37.00
39      mobile: (+32).81.81.37.00
40      section_id: crm_case_section_demosalesteam
41      referred: False
42      type: lead
43 -
44    I check that the lead is in 'draft' state,
45 -
46    !assert {model: crm.lead, id: crm_lead_democustomer, string: Lead in Draft}:
47      - state == "draft"
48 -
49    I create categories.
50 -
51    !record {model: crm.case.categ, id: crm_case_categ0}:
52      name: crm_case_section_demosalesteam
53      section_id: crm_case_section_demosalesteam
54 -
55   I assigning contact detail to the Lead "Demo Customer" without address.
56 -
57   !python {model: crm.lead}: |
58     self.onchange_partner_address_id(cr, uid, ref("crm_lead_democustomer"), None, email=False)
59
60 -
61   I assigning contact detail to the Lead "Demo Customer" with address.
62 -
63   !python {model: crm.lead}: |
64     self.onchange_partner_address_id(cr, uid, ref("crm_lead_democustomer"), ref("base.res_partner_address_notsotinysarl0"), email=False)    
65
66 -
67   I selecting email "Opt-out" option for the "Demo Customer" Lead.
68 -
69   !python {model: crm.lead}: |
70     self.on_change_optout(cr, uid, ref("crm_lead_democustomer"), True)
71
72 -
73   Now I change the Opt-out to Opt-in to show email receive preference.
74 -
75   !python {model: crm.lead}: |
76     self.on_change_optin(cr, uid, ref("crm_lead_democustomer"), True)
77 -
78    I open lead by click on "Open" button,
79 -
80    !python {model: crm.lead}: |
81      self.case_open(cr, uid, [ref("crm_lead_democustomer")])
82 -
83   I check that lead "Demo Customer" is now in 'open' state.
84 -
85   !assert {model: crm.lead, id: crm_lead_democustomer, string: Lead in open state}:
86      - state == "open"
87 -
88   Now i reset the lead "Demo Customer".
89 -
90     !python {model: crm.lead}: |
91       self.case_reset(cr, uid, [ref("crm_lead_democustomer")])
92 -
93    I again opening lead by click on "Open" button,
94 -
95    !python {model: crm.lead}: |
96      self.case_open(cr, uid, [ref("crm_lead_democustomer")])
97 -
98   I setting stage "New" for the lead "Demo Customer".
99 -
100    !python {model: crm.lead}: |
101      self.stage_next(cr, uid, [ref("crm_lead_democustomer")], context={'stage_type': 'lead'})
102 -
103   I try to Unlink the Lead "Demo Customer" demo Lead
104 -
105    !python {model: crm.lead}: |
106     try:
107       self.unlink(cr, uid, [ref("crm_lead_democustomer")])
108     except:
109       pass
110 -
111    I setting Lead "Demo Customer" to Pending State
112 -
113     !python {model: crm.lead}: |
114       self.case_pending(cr, uid, [ref("crm_lead_democustomer")])
115 -
116   I check that lead "Demo Customer" is now in 'Pending' state.
117 -
118   !assert {model: crm.lead, id: crm_lead_democustomer, string: Lead in Pending state}:
119      - state == "pending"
120 -
121   Now i Escalate the Lead "Demo Customer" Parent "Sales Team".
122 -
123     !python {model: crm.lead}: |
124       self.case_escalate(cr, uid, [ref("crm_lead_democustomer")])
125
126   Now i add Internal Note Saying Escalated Reason
127   Creating a crm.add.note record
128
129   !record {model: crm.add.note, id: crm_add_note_0}:
130     body: Sales Lead Has Been Escalated Due to Some Technical reason to the parent  'Sales
131       Team'
132     state: unchanged
133 -
134   I click aa note button to attach the record
135
136   !python {model: crm.add.note}: |
137     context['active_model'] = "crm.lead"
138     context['active_ids'] = [ref("crm_lead_democustomer")]
139     self.action_add(cr, uid, [ref("crm_add_note_0")], context=context)
140
141 -
142   Now i Copying this lead "Demo Customer" to New Lead.
143 -
144     !python {model: crm.lead}: |
145       self.copy(cr, uid, ref("crm_lead_democustomer"))
146 -
147   Checking the Lead Copied or Not.
148 -
149     !python {model: crm.lead}: |
150       sid = self.search(cr, uid, [('name', '=', 'Demo Customer'),('state', '=', 'draft')])
151       if not sid:
152         raise AssertionError("Lead is not copied Successfully")
153