9f63bd6baa71979be82cae304b18823f64c5c27f
[odoo/odoo.git] / addons / hr_timesheet / test / test_hr_timesheet.yml
1 -
2   In order to test hr_timesheet Module in OpenERP, I make "Sign In/Sign Out for Project" to encode and
3   track time spent on the different projects.
4
5 -
6   I  create a new employee “Mark Johnson” to test Timesheet.
7 -
8   !record {model: hr.employee, id: hr_employee_employee0}:
9     address_home_id: base.res_partner_address_1
10     company_id: base.main_company
11     gender: male
12     marital: hr.hr_employee_marital_status_single
13     name: Mark Johnson
14     user_id: base.user_root
15
16 -
17   I create new user "test_timesheet_user1".
18 -
19   !record {model: res.users, id: test_timesheet_user1}:
20     company_id: base.main_company
21     context_lang: en_US
22     groups_id:
23       - base.group_hr_user
24       - base.group_user
25       - base.group_extended
26       - base.group_hr_manager
27     login: test_timesheet_user1
28     name: test_timesheet_user1
29     password: test_timesheet_user1
30
31 -
32   I create another new employee "Francline" as "test_timesheet_user1".
33 -
34   !record {model: hr.employee, id: hr_employee_fracline1}:
35     address_home_id: base.res_partner_address_8
36     name: Francline
37     parent_id: 'hr_employee_employee0'
38     user_id: 'test_timesheet_user1'
39
40 -
41   I create Timesheet journal for employee.
42 -
43   !record {model: account.analytic.journal, id: analytic_journal}:
44     code: TS
45     name: Timesheet Journal
46     type: general
47
48 -
49   I create a product as "Consultancy - Senior Developer".
50 -
51   !record {model: product.product, id: product_consultant}:
52     categ_id: product.product_category_10
53     default_code: DEV
54     list_price: 75.0
55     name: Consultancy - Senior Developer
56     procure_method: make_to_order
57     purchase_ok: False
58     standard_price: 30.0
59     supply_method: produce
60     type: service
61     uom_id: product.uom_hour
62     uom_po_id: product.uom_hour
63
64 -
65   I assigned product and journal to  "Mark Johnson"
66 -
67   !record {model: hr.employee, id: hr_employee_employee0}:
68     product_id: product_consultant
69     journal_id: analytic_journal
70 -
71   I assigned product and journal to "Francline".
72 -
73   !record {model: hr.employee, id: hr_employee_fracline1}:
74     product_id: product_consultant
75     journal_id: analytic_journal
76 -
77   I create attendance and perform "Sign In" action with proper reason.
78 -
79   !record {model: hr.attendance, id: hr_attendance_0}:
80     action: sign_in
81     employee_id: 'hr_employee_fracline1'
82     name: !eval time.strftime('%Y-%m-%d 10:00:00')
83
84 -
85   I create attendance and perform "Sign Out" action.
86 -
87   !record {model: hr.attendance, id: hr_attendance_1}:
88     action: sign_out
89     employee_id: 'hr_employee_fracline1'
90     name: !eval time.strftime('%Y-%m-%d 11:00:00')
91
92 -
93   On "Sign In/Sign Out by Project" wizard I click on "Sign In/Sign Out" button of this wizard.
94 -
95   !python {model: hr.sign.in.project}: |
96     uid = ref('test_timesheet_user1')
97     self.check_state(cr, uid, [ref("hr_employee_fracline1")], {"active_ids": [ref("hr_timesheet.action_hr_timesheet_sign_in")]})
98 -
99   I select start date and Perform start work on project.
100 -
101   !python {model: hr.sign.in.project}: |
102       import time
103       uid = ref('test_timesheet_user1'),
104       new_id = self.create(cr, uid, {'emp_id': ref('hr_employee_fracline1'), 'name': 'Francline', 'server_date': time.strftime('%Y-%m-%d %H:%M:%S'), 'date': time.strftime('%Y-%m-%d 12:%M:%S'), 'state': 'absent'})
105       self.sign_in_result(cr, uid, [new_id], context)
106
107 -
108   To stop work I click on "Sign In/Sign Out" button of "Sign In/Sign Out by Project" wizard.
109   Which check state in hr attendace form for user.
110 -
111   !python {model: hr.sign.in.project}: |
112        uid = ref('test_timesheet_user1')
113        ids = self.search(cr, uid, [('emp_id', '=', ref('hr_employee_fracline1')),('name', '=', 'Francline')])
114        self.check_state(cr, uid, ids, {"active_ids": [ref("hr_timesheet.action_hr_timesheet_sign_in")]
115              })
116
117 -
118   I Create an analytic account "Project2".
119 -
120   !record {model: account.analytic.account, id: account_analytic_account_project0}:
121     company_id: base.main_company
122     name: Project2
123     parent_id: account.analytic_root
124     quantity_max: 0.0
125     state: open
126
127 -
128   My work for this project is over and I stop working by clicking on "Stop Work" button of this wizard.
129 -
130   !python {model: hr.sign.out.project}: |
131        import time
132        from datetime import datetime, date, timedelta
133        uid = ref('test_timesheet_user1')
134        new_id = self.create(cr, uid, {'account_id': ref('account_analytic_account_project0'), 'analytic_amount': 6.0, 'date': time.strftime('%Y-%m-%d 18:%M:%S'), 'date_start': time.strftime('%Y-%m-%d %H:%M:%S'), 'info': 'Create Yaml for hr module', 'name': 'Francline', 'server_date': time.strftime('%Y-%m-%d %H:%M:%S'), 'state': 'absent'})
135        self.sign_out_result_end(cr, uid, [new_id], context)
136
137 - |
138   I can see employee timesheet for particular month using "Employee Timesheet" report.