[IMP] hr, hr_xxx: Improved yamls to save data fetched from on change methods.
[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: 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 a product as "Consultancy - Senior Developer".
42 -
43   !record {model: product.product, id: product_consultant}:
44     categ_id: product.product_category_10
45     default_code: DEV
46     list_price: 75.0
47     name: Consultancy - Senior Developer
48     procure_method: make_to_order
49     purchase_ok: False
50     standard_price: 30.0
51     supply_method: produce
52     type: service
53     uom_id: product.uom_hour
54     uom_po_id: product.uom_hour
55
56 -
57   I assigned product and journal to  "Mark Johnson"
58 -
59   !record {model: hr.employee, id: hr_employee_employee0}:
60     product_id: product_consultant
61     journal_id: analytic_journal
62 -
63   I assigned product and journal to "Francline".
64 -
65   !record {model: hr.employee, id: hr_employee_fracline1}:
66     product_id: product_consultant
67     journal_id: analytic_journal
68 -
69   I create attendance and perform "Sign In" action with proper reason.
70 -
71   !record {model: hr.attendance, id: hr_attendance_0}:
72     action: sign_in
73     employee_id: 'hr_employee_fracline1'
74     name: !eval (datetime.now()-timedelta(hours=2)).strftime('%Y-%m-%d %H:%M:%S')
75
76 -
77   I create attendance and perform "Sign Out" action.
78 -
79   !record {model: hr.attendance, id: hr_attendance_1}:
80     action: sign_out
81     employee_id: 'hr_employee_fracline1'
82     name: !eval (datetime.now()-timedelta(hours=1)).strftime('%Y-%m-%d %H:%M:%S')
83
84 -
85   On "Sign In/Sign Out by Project" wizard i click on "Sign In/Sign Out" button of this wizard.
86 -
87   !python {model: hr.sign.in.project}: |
88     uid = ref('test_timesheet_user1')
89     self.check_state(cr, uid, [ref("hr_employee_fracline1")], {"active_ids": [ref("hr_timesheet.action_hr_timesheet_sign_in")]})
90 -
91   I select start date and Perform start work on project.
92 -
93   !python {model: hr.sign.in.project}: |
94       import time
95       uid = ref('test_timesheet_user1')
96       new_id = self.create(cr, uid, {'emp_id': ref('hr_employee_fracline1'), 'name': 'Francline', 'server_date': time.strftime('%Y-%m-%d %H:%M:%S'), 'state': 'absent'})
97       self.sign_in_result(cr, uid, [new_id], context)
98 -
99   I create a timesheet line manually to check several default values. 
100   I also assign proper date and user for that line.
101 -
102   !python {model: hr.analytic.timesheet}: |
103      import time
104      uid = ref('test_timesheet_user1')
105      current_date = time.strftime('%Y-%m-%d')
106      vals = {'name': 'Worked on project',
107              'user_id': ref('test_timesheet_user1'),
108              'account_id': ref('account.analytic_project_1_development'),
109              'unit_amount': 5.00,
110              'journal_id': ref('analytic_journal')
111      }
112      line_id = self.create(cr, uid, vals, None)
113      res = self.on_change_date(cr, uid, [line_id], current_date)
114      values = dict([('date', current_date)] + res['value'].items())
115      res1 = self.on_change_user_id(cr, uid, [line_id], ref('base.user_root'))
116      values.update(dict([('user_id', ref('base.user_root'))] + res1['value'].items()))
117      self.write(cr, uid, [line_id], values, None)
118 -
119   To stop work I click on "Sign In/Sign Out" button of "Sign In/Sign Out by Project" wizard.
120   Which check state in hr attendace form for user.
121 -
122   !python {model: hr.sign.in.project}: |
123        uid = ref('test_timesheet_user1')
124        ids = self.search(cr, uid, [('emp_id', '=', ref('hr_employee_fracline1')),('name', '=', 'Francline')])
125        self.check_state(cr, uid, ids, {"active_ids": [ref("hr_timesheet.action_hr_timesheet_sign_in")]
126              })
127 -
128   I Create an analytic account "Project2".
129 -
130   !record {model: account.analytic.account, id: account_analytic_account_project0}:
131     company_id: base.main_company
132     name: Project2
133     parent_id: account.analytic_root
134     quantity_max: 0.0
135     state: open
136
137 -
138   My work for this project is over and I stop working by clicking on "Stop Work" button of this wizard.
139 -
140   !python {model: hr.sign.out.project}: |
141        import time
142        from datetime import datetime, date, timedelta
143        uid = ref('test_timesheet_user1')
144        new_id = self.create(cr, uid, {'account_id': ref('account_analytic_account_project0'), 'analytic_amount': 7.0, 'date': (datetime.now()+timedelta(1)).strftime('%Y-%m-%d %H:%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'})
145        self.sign_out_result_end(cr, uid, [new_id], context)
146
147 - |
148   I can see employee timesheet for particular month using "Employee Timesheet" report.
149