720636dbe38f54ecca9c07c8ad084e5c598f03af
[odoo/odoo.git] / addons / hr_holidays / test / test_hr_holiday.yml
1 -
2   In order to test the hr_holiday module in OpenERP, I will  Allocate leaves for Employee and manage leaves and leaves requests.
3 -
4   I create new user "test_holiday_user1" who will make leave request.
5 -
6   !record {model: res.users, id: test_holiday_user1}:
7     company_id: base.main_company
8     context_lang: en_US
9     groups_id:
10       - base.group_user
11       - base.group_hr_manager
12       - base.group_hr_user
13     login: test_holiday_user1
14     name: test_holiday_user1
15     password: test_holiday_user1
16 -
17   I create a new employee “Mark Johnshon” as Manager to validate employee leave.
18 -
19   !record {model: hr.employee, id: hr_employee_employee0}:
20     address_home_id: base.res_partner_address_1
21     company_id: base.main_company
22     gender: male
23     name: Mark Johnson
24     user_id: base.user_root
25 -
26   I Create another employee "Phil Graves" as "test_holiday_user1".
27 -
28   !record {model: hr.employee, id: hr_employee_philgraves0}:
29     address_home_id: base.res_partner_address_8
30     name: Phil Graves
31     parent_id: 'hr_employee_employee0'
32     user_id: 'test_holiday_user1'
33 -
34   I create a new Leave type "Sick Leave".
35 -
36   !record {model: hr.holidays.status, id: hr_holidays_status_sick0}:
37     color_name: red
38     name: Sick Leave.
39     limit: 12
40
41 -
42   I allocate leave request for employee "Phil Graves".
43 -
44   !record {model: hr.holidays, id: hr_holidays_allocateleaveforuser0}:
45     holiday_status_id: hr_holidays_status_sick0
46     name: Sick Leaves for Phil Graves
47     number_of_days_temp: 12.0
48     date_from: !eval "'%s-05-20 13:59:00' %(datetime.now().year)"
49     date_to: !eval "'%s-05-22 13:59:00' %(datetime.now().year)"
50     type: add
51 -
52   I assign allocation type as 'Employee'.
53 -
54   !python {model: hr.holidays}: |
55     self.onchange_type(cr, uid, [ref('hr_holidays_allocateleaveforuser0')], 'employee')
56 -
57   I change Leave Type of the employee.
58 -
59   !python {model: hr.holidays}: |
60     self.onchange_sec_id(cr, uid, [ref('hr_holidays_allocateleaveforuser0')], ref('holiday_status_sl'))
61 -
62   I assign the dates in the holiday request.
63 -
64   !python {model: hr.holidays}: |
65     from datetime import datetime
66     date_from = '%s-%s-%s 14:00:00' %(datetime.now().year, datetime.now().month, datetime.now().day)
67     date_to = '%s-%s-%s 19:59:00' %(datetime.now().year, datetime.now().month, datetime.now().day)
68     self.onchange_date_from(cr, uid, [ref('hr_holidays_allocateleaveforuser0')], date_to, date_from)
69 -
70   I confirmed the allocation by clicking on "Confirm" button.
71 -
72   !workflow {model: hr.holidays, action: confirm, ref: hr_holidays_allocateleaveforuser0}
73
74 -
75   I find a small mistake on my leave request to I refuse the leave request to correct a mistake.
76 -
77   !workflow {model: hr.holidays, action: refuse, ref: hr_holidays_allocateleaveforuser0}
78
79 -
80   I again set to draft and then confirm.
81 -
82   !python {model: hr.holidays}: |
83      import netsvc
84      wf_service = netsvc.LocalService("workflow")
85      self.set_to_draft(cr, uid, [ref('hr_holidays_allocateleaveforuser0')])
86      wf_service.trg_validate(uid, 'hr.holidays', ref('hr_holidays_allocateleaveforuser0'), 'confirm', cr)
87 -
88   I validate the allocation by clicking on "To Approve" button.
89 -
90   !workflow {model: hr.holidays, action: validate,  ref: hr_holidays_allocateleaveforuser0}
91
92 -
93   I connect as "test_holiday_user1", and create a new leave request for employee "Phil Graves".
94 -
95   !record {model: hr.holidays, id: hr_holidays_iwanttoleaveforgotohospital0}:
96     date_from: !eval "'%s-05-20 11:48:00' %(datetime.now().year)"
97     date_to: !eval "'%s-05-21 11:48:00' %(datetime.now().year)"
98     employee_id: 'hr_employee_philgraves0'
99     holiday_status_id: 'hr_holidays_status_sick0'
100     name: Appointment with Doctor
101     notes: My appointment with the doctor is confirmed. So please accept my leave.
102     number_of_days_temp: 2.0
103     type: remove
104     user_id: 'test_holiday_user1'
105 -
106   I check that Leave Request is in "Draft" state.
107 -
108   !assert {model: hr.holidays, id: hr_holidays_iwanttoleaveforgotohospital0}:
109     - state == 'draft'
110
111 -
112   I confirm leave Request by click on "Confirm" button.
113 -
114   !workflow {model: hr.holidays, action: confirm, ref: hr_holidays_iwanttoleaveforgotohospital0}
115
116 -
117   I connect as "Admin" user and Open Leave request of "Phil Graves" and "validate" it by click on "Approve" button.
118 -
119   !workflow {model: hr.holidays, action: validate,  ref: hr_holidays_iwanttoleaveforgotohospital0}
120
121 -
122   I check that "Leave Manager" field is automatically filled by the user who validate the leave'.
123 -
124   !python {model: hr.holidays}: |
125      ids2 = self.pool.get('hr.employee').search(cr, uid, [('user_id','=', uid)])
126      obj = self.browse(cr, uid, ref('hr_holidays_iwanttoleaveforgotohospital0'))
127      assert ids2[0] == obj.manager_id.id
128
129 -
130   I check that Leave request state is "Validated".
131 -
132   !assert {model: hr.holidays, id: hr_holidays_iwanttoleaveforgotohospital0}:
133     - state == "validate"
134
135 -
136   I can also see Summary of Employee's holiday by using 'Employee's Holidays' Report. This report will allows to choose to print holidays with state Confirmed, Validated or both.