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.
6 I create a new employee “Mark Johnson” to test Timesheet.
8 !record {model: hr.employee, id: hr_employee_employee0}:
9 address_home_id: base.res_partner_address_1
10 company_id: base.main_company
14 user_id: base.user_root
17 I create new user "test_timesheet_user1".
19 !record {model: res.users, id: test_timesheet_user1}:
20 company_id: base.main_company
26 - base.group_hr_manager
27 login: test_timesheet_user1
28 name: test_timesheet_user1
29 password: test_timesheet_user1
32 I create another new employee "Francline" as "test_timesheet_user1".
34 !record {model: hr.employee, id: hr_employee_fracline1}:
35 address_home_id: base.res_partner_address_8
37 parent_id: 'hr_employee_employee0'
38 user_id: 'test_timesheet_user1'
41 I create a product as "Consultancy - Senior Developer".
43 !record {model: product.product, id: product_consultant}:
44 categ_id: product.product_category_10
47 name: Consultancy - Senior Developer
48 procure_method: make_to_order
51 supply_method: produce
53 uom_id: product.uom_hour
54 uom_po_id: product.uom_hour
57 I assigned product and journal to "Mark Johnson"
59 !record {model: hr.employee, id: hr_employee_employee0}:
60 product_id: product_consultant
61 journal_id: analytic_journal
63 I assigned product and journal to "Francline".
65 !record {model: hr.employee, id: hr_employee_fracline1}:
66 product_id: product_consultant
67 journal_id: analytic_journal
69 I create attendance and perform "Sign In" action with proper reason.
71 !record {model: hr.attendance, id: hr_attendance_0}:
73 employee_id: 'hr_employee_fracline1'
74 name: !eval (datetime.now()-timedelta(hours=2)).strftime('%Y-%m-%d %H:%M:%S')
77 I create attendance and perform "Sign Out" action.
79 !record {model: hr.attendance, id: hr_attendance_1}:
81 employee_id: 'hr_employee_fracline1'
82 name: !eval (datetime.now()-timedelta(hours=1)).strftime('%Y-%m-%d %H:%M:%S')
85 On "Sign In/Sign Out by Project" wizard i click on "Sign In/Sign Out" button of this wizard.
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")]})
91 I select start date and Perform start work on project.
93 !python {model: hr.sign.in.project}: |
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)
99 I create a timesheet line manually to check several default values.
100 I also assign proper date and user for that line.
102 !python {model: hr.analytic.timesheet}: |
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'),
110 'journal_id': ref('analytic_journal')
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)
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.
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")]
128 I Create an analytic account "Project2".
130 !record {model: account.analytic.account, id: account_analytic_account_project0}:
131 company_id: base.main_company
133 parent_id: account.analytic_root
138 My work for this project is over and I stop working by clicking on "Stop Work" button of this wizard.
140 !python {model: hr.sign.out.project}: |
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)
148 I can see employee timesheet for particular month using "Employee Timesheet" report.