2 I test the "Payslip" in order to check the hr_payroll_account module in OpenERP.
4 I create a bank record.
6 !record {model: res.partner.bank, id: res_partner_bank_0}:
7 acc_number: '001-9876543-21'
8 partner_id: base.res_partner_12
12 I create a new employee "John".
14 !record {model: hr.employee, id: hr_employee_john}:
15 address_home_id: base.res_partner_address_2
16 address_id: base.res_partner_address_9
17 birthday: '1984-05-01'
20 department_id: hr.dep_rd
24 bank_account_id: res_partner_bank_0
27 I create a salary structure for 'Software Developer'.
29 !record {model: hr.payroll.structure, id: hr_payroll_structure_softwaredeveloper}:
30 name: Salary Structure for Software Developer
32 company_id: base.main_company
33 parent_id: hr_payroll.structure_base
35 - hr_payroll.hr_salary_rule_houserentallowance1
36 - hr_payroll.hr_salary_rule_convanceallowance1
37 - hr_payroll.hr_salary_rule_professionaltax1
38 - hr_payroll.hr_salary_rule_providentfund1
39 - hr_payroll.hr_salary_rule_meal_voucher
40 - hr_payroll.hr_salary_rule_sales_commission
42 I create a contract for "John".
44 !record {model: hr.contract, id: hr_contract_john}:
45 date_end: !eval "(datetime.now() + timedelta(days=365)).strftime('%Y-%m-%d')"
46 date_start: !eval time.strftime('%Y-%m-%d')
47 name: Contract for John
49 type_id: hr_contract.hr_contract_type_emp
50 employee_id: hr_employee_john
51 struct_id: hr_payroll_structure_softwaredeveloper
52 working_hours: resource.timesheet_group1
53 journal_id: account.expenses_journal
57 !record {model: hr.payslip, id: hr_payslip_0}:
58 employee_id: hr_employee_john
59 journal_id: account.expenses_journal
62 The selection of an employee fills the contract, structure, worked days and input data fields.
64 !python {model: hr.payslip}: |
66 from datetime import datetime
67 from dateutil import relativedelta
68 date_from = time.strftime('%Y-%m-01')
69 worked_days_obj = self.pool.get('hr.payslip.worked_days')
70 date_to = str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10]
71 res = self.onchange_employee_id(cr, uid, [], date_from, date_to, ref("hr_employee_john"), False, None)
73 'struct_id': res['value']['struct_id'],
74 'contract_id': res['value']['contract_id'],
75 'name': res['value']['name'],
77 vals['worked_days_line_ids'] = [(0,0,i) for i in res['value']['worked_days_line_ids']]
78 vals['input_line_ids'] = [(0,0,i) for i in res['value']['input_line_ids']]
79 res_contract = self.onchange_contract_id(cr, uid, [ref('hr_payslip_0')], date_from, date_to, ref('hr_employee_john'), ref('hr_contract_john'), None)
80 vals.update({'contract_id': ref('hr_contract_john')})
81 self.write(cr, uid, ref("hr_payslip_0"), vals)
83 I assign the amount to Input data.
85 !python {model: hr.payslip.input}: |
86 ids = self.search(cr, uid, [('payslip_id', '=', ref("hr_payslip_0"))])
87 self.write(cr, uid, ids, {'amount': 5.0})
89 I verify the payslip is in draft state.
91 !python {model: hr.payslip}: |
92 payslip_brw=self.browse(cr, uid, ref("hr_payslip_0"))
93 assert(payslip_brw.state == 'draft'), 'State not changed!'
95 I click on "Compute Sheet" button.
97 !python {model: hr.payslip}: |
98 self.compute_sheet(cr, uid, [ref("hr_payslip_0")], {"lang": "en_US", "tz": False,
99 "active_model": "ir.ui.menu", "department_id": False, "active_ids": [ref("hr_payroll.menu_department_tree")],
100 "section_id": False, "active_id": ref("hr_payroll.menu_department_tree"),
103 I want to check cancel button. So I first cancel the sheet then make it set to draft.
105 !python {model: hr.payslip}: |
106 self.cancel_sheet(cr, uid, [ref("hr_payslip_0")], None)
107 self.signal_draft(cr, uid, [ref("hr_payslip_0")])
109 Then I click on the "Confirm" button.
111 !workflow {model: hr.payslip, action: hr_verify_sheet, ref: hr_payslip_0}
113 I verify that the Accounting Entries are created.
115 !python {model: hr.payslip}: |
116 payslip = self.browse(cr, uid, ref("hr_payslip_0"))
117 assert payslip.move_id, "Accounting Entries has not been created"
119 I verify that the payslip is in done state.
121 !python {model: hr.payslip}: |
122 payslip_brw=self.browse(cr, uid, ref("hr_payslip_0"))
123 assert(payslip_brw.state == 'done'), 'State not changed!'