2 I test "Payslip" in order to check the hr_payroll module in OpenERP
4 I create a new employee "Richard"
6 !record {model: hr.employee, id: hr_employee_richard0}:
9 department_id: hr.dep_rd
13 I create a salary structure for "Software Developer"
15 !record {model: hr.payroll.structure, id: hr_payroll_structure_softwaredeveloper}:
16 name: Salary Structure for Software Developer
18 company_id: base.main_company
20 - hr_salary_rule_houserentallowance1
21 - hr_salary_rule_convanceallowance1
22 - hr_salary_rule_professionaltax1
23 - hr_salary_rule_providentfund1
24 - hr_salary_rule_meal_voucher
25 - hr_salary_rule_sales_commission
27 I create a contract for "Richard"
29 !record {model: hr.contract, id: hr_contract_richard}:
30 date_end: !eval "(datetime.now() + timedelta(days=365)).strftime('%Y-%m-%d')"
31 date_start: !eval time.strftime('%Y-%m-%d')
32 name: Contract for Richard
34 type_id: hr_contract.hr_contract_type_emp
35 employee_id: hr_employee_richard0
36 struct_id: hr_payroll_structure_softwaredeveloper
37 working_hours: resource.timesheet_group1
39 I create a Employee Payslip
41 !record {model: hr.payslip, id: hr_payslip_0}:
42 employee_id: hr_payroll.hr_employee_richard0
44 I assign the amount to Input data
46 !python {model: hr.payslip.input}: |
47 ids = self.search(cr, uid, [('payslip_id', '=', ref("hr_payslip_0"))])
48 self.write(cr, uid, ids, {'amount': 5.0})
50 I verify the payslip is in draft state
52 !python {model: hr.payslip}: |
53 payslip_brw=self.browse(cr, uid, ref("hr_payslip_0"))
54 assert (payslip_brw.state == 'draft'), 'State not changed!'
56 I click on 'Compute Sheet' button on payslip
58 !python {model: hr.payslip}: |
59 self.compute_sheet(cr, uid, [ref("hr_payslip_0")], {"lang": "en_US", "tz": False,
60 "active_model": "ir.ui.menu", "department_id": False, "active_ids": [ref("hr_payroll.menu_department_tree")],
61 "section_id": False, "active_id": ref("hr_payroll.menu_department_tree"),
64 Then I click on the 'Confirm' button on payslip
66 !workflow {model: hr.payslip, action: hr_verify_sheet, ref: hr_payslip_0}
68 I verify that the payslip is in done state
70 !python {model: hr.payslip}: |
71 payslip_brw=self.browse(cr, uid, ref("hr_payslip_0"))
72 assert(payslip_brw.state == 'done'), 'State not changed!'
74 I want to check refund payslip so I click on refund button.
76 !python {model: hr.payslip}: |
77 self.refund_sheet(cr, uid, [ref("hr_payslip_0")], None)
79 I check on new payslip Credit Note is checked or not.
81 !python {model: hr.payslip}: |
82 payslip_obj = self.browse(cr, uid, ref("hr_payslip_0"), None)
83 payslip_ids = self.search(cr, uid, [('name','like','Refund: '+payslip_obj.name),('credit_note','=',True)], None)
84 assert payslip_ids, "Payslip not refunded!"
86 I want to generate a payslip from Payslip run.
88 !record {model: hr.payslip.run, id: hr_payslip_run_PayslipforEmployee0}:
89 date_end: '2011-09-30'
90 date_start: '2011-09-01'
91 name: Payslip for Employee
93 I create record for generating the payslip for this Payslip run.
95 !record {model: hr.payslip.employees, id: hr_payslip_employees0}:
97 - hr_employee_richard0
99 I generate the payslip by clicking on Generat button wizard.
101 !python {model: hr.payslip.employees}: |
102 self.compute_sheet(cr, uid, [ref('hr_payslip_employees0')], context={'active_id': ref('hr_payslip_run_PayslipforEmployee0')})
104 I open Contribution Register and from there I print the Payslip Lines report.
106 !record {model: payslip.lines.contribution.register, id: payslip_lines_contribution_register0}:
107 date_from: '2011-09-30'
108 date_to: '2011-09-01'
110 I print the payslip report
112 !python {model: hr.payslip}: |
114 import openerp.report
115 from openerp import tools
116 data, format = openerp.report.render_report(cr, uid, [ref('hr_payslip_0')], 'hr_payroll.report_payslip', {}, {})
117 if tools.config['test_report_directory']:
118 file(os.path.join(tools.config['test_report_directory'], 'hr_payroll-payslip.'+format), 'wb+').write(data)
120 I print the payslip details report
122 !python {model: hr.payslip}: |
124 import openerp.report
125 from openerp import tools
126 data, format = openerp.report.render_report(cr, uid, [ref('hr_payslip_0')], 'hr_payroll.report_payslipdetails', {}, {})
127 if tools.config['test_report_directory']:
128 file(os.path.join(tools.config['test_report_directory'], 'hr_payroll-payslipdetails.'+format), 'wb+').write(data)
130 I print the contribution register report
132 !python {model: hr.contribution.register}: |
133 ctx={'model': 'hr.contribution.register', 'active_ids': [ref('hr_houserent_register')]}
134 from openerp.tools import test_reports
135 test_reports.try_report_action(cr, uid, 'action_payslip_lines_contribution_register', context=ctx, our_module='hr_payroll')