[IMP]crm : Improve the code
[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    !record {model: res.users, id: res_users_usercrm0}:
27      context_section_id: crm_case_section_demosalesteam    
28 -  |
29    Creating a new lead "Demo Customer" and I provide an address to this
30    demo customer and email "info@democustomer.com" and Also "Demo Sales Team".
31 -
32    !record {model: crm.lead, id: crm_lead_democustomer}:
33      email_from: info@democustomer.com
34      name: Demo Customer
35      partner_name: NotSoTinySARL
36      phone: (+32).81.81.37.00
37      mobile: (+32).81.81.37.00
38      section_id: crm_case_section_demosalesteam
39      referred: False
40      type: lead
41 -
42    I check that the lead is in 'draft' state,
43 -
44    !assert {model: crm.lead, id: crm_lead_democustomer, string: Lead in Draft}:
45      - state == "draft"
46 -
47   I assigning contact detail to the Lead "Demo Customer" without address.
48 -
49   !python {model: crm.lead}: |
50     self.onchange_partner_address_id(cr, uid, ref("crm_lead_democustomer"), None, email=False)
51
52 -
53   I assigning contact detail to the Lead "Demo Customer" with address.
54 -
55   !python {model: crm.lead}: |
56     self.onchange_partner_address_id(cr, uid, ref("crm_lead_democustomer"), ref("base.res_partner_address_notsotinysarl0"), email=False)    
57
58 -
59   I selecting email "Opt-out" option for the "Demo Customer" Lead.
60 -
61   !python {model: crm.lead}: |
62     self.on_change_optout(cr, uid, ref("crm_lead_democustomer"), True)
63
64 -
65   Now I change the Opt-out to Opt-in to show email receive preference.
66 -
67   !python {model: crm.lead}: |
68     self.on_change_optin(cr, uid, ref("crm_lead_democustomer"), True)
69 -
70    I open lead by click on "Open" button,
71 -
72    !python {model: crm.lead}: |
73      self.case_open(cr, uid, [ref("crm_lead_democustomer")])
74 -
75   I check that lead "Demo Customer" is now in 'open' state.
76 -
77   !assert {model: crm.lead, id: crm_lead_democustomer, string: Lead in open state}:
78      - state == "open"
79 -
80   Now i reset the lead "Demo Customer".
81 -
82     !python {model: crm.lead}: |
83       self.case_reset(cr, uid, [ref("crm_lead_democustomer")])
84 -
85    I again opening lead by click on "Open" button,
86 -
87    !python {model: crm.lead}: |
88      self.case_open(cr, uid, [ref("crm_lead_democustomer")])
89 -
90   I setting stage "New" for the lead "Demo Customer".
91 -
92    !python {model: crm.lead}: |
93      self.stage_next(cr, uid, [ref("crm_lead_democustomer")], context={'stage_type': 'lead'})
94 -
95   I try to Unlink the Lead "Demo Customer" demo Lead
96 -
97    !python {model: crm.lead}: |
98     try:
99       self.unlink(cr, uid, [ref("crm_lead_democustomer")])
100     except:
101       pass
102 -
103    I setting Lead "Demo Customer" to Pending State
104 -
105     !python {model: crm.lead}: |
106       self.case_pending(cr, uid, [ref("crm_lead_democustomer")])
107 -
108   I check that lead "Demo Customer" is now in 'Pending' state.
109 -
110   !assert {model: crm.lead, id: crm_lead_democustomer, string: Lead in Pending state}:
111      - state == "pending"
112 -
113   Now i Escalate the Lead "Demo Customer" Parent "Sales Team".
114 -
115     !python {model: crm.lead}: |
116       self.case_escalate(cr, uid, [ref("crm_lead_democustomer")])
117
118   Now i add Internal Note Saying Escalated Reason
119   Creating a crm.add.note record
120
121   !record {model: crm.add.note, id: crm_add_note_0}:
122     body: Sales Lead Has Been Escalated Due to Some Technical reason to the parent  'Sales
123       Team'
124     state: unchanged
125 -
126   I click aa note button to attach the record
127
128   !python {model: crm.add.note}: |
129     context['active_model'] = "crm.lead"
130     context['active_ids'] = [ref("crm_lead_democustomer")]
131     self.action_add(cr, uid, [ref("crm_add_note_0")], context=context)
132
133 -
134   Now i Copying this lead "Demo Customer" to New Lead.
135 -
136     !python {model: crm.lead}: |
137       self.copy(cr, uid, ref("crm_lead_democustomer"))
138 -
139   Checking the Lead Copied or Not.
140 -
141     !python {model: crm.lead}: |
142       sid = self.search(cr, uid, [('name', '=', 'Demo Customer'),('state', '=', 'draft')])
143       if not sid:
144         raise AssertionError("Lead is not copied Successfully")
145