[FIX] hr*: must depend on "report" module
[odoo/odoo.git] / addons / hr_payroll / test / payslip.yml
1 -
2   I test "Payslip" in order to check the hr_payroll module in OpenERP
3 -
4   I create a new employee "Richard"
5 -
6   !record {model: hr.employee, id: hr_employee_richard0}:
7     birthday: '1984-05-01'
8     country_id: base.be
9     department_id: hr.dep_rd
10     gender: male
11     name: Richard
12 -
13   I create a salary structure for "Software Developer"
14 -
15   !record {model: hr.payroll.structure, id: hr_payroll_structure_softwaredeveloper}:
16     name: Salary Structure for Software Developer
17     code: SD
18     company_id: base.main_company
19     rule_ids:
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
26 -
27   I create a contract for "Richard"
28 -
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
33     wage: 5000.0
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
38 -
39   I create a Employee Payslip
40 -
41   !record {model: hr.payslip, id: hr_payslip_0}:
42     employee_id: hr_payroll.hr_employee_richard0
43 -
44   I assign the amount to Input data
45 -
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})
49 -
50   I verify the payslip is in draft state
51 -
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!'
55 -
56   I click on 'Compute Sheet' button on payslip
57 -
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"),
62       })
63 -
64   Then I click on the 'Confirm' button on payslip
65 -
66   !workflow {model: hr.payslip, action: hr_verify_sheet, ref: hr_payslip_0}
67 -
68   I verify that the payslip is in done state
69 -
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!'
73 -
74   I want to check refund payslip so I click on refund button.
75 -
76   !python {model: hr.payslip}: |
77     self.refund_sheet(cr, uid, [ref("hr_payslip_0")], None)
78 -
79   I check on new payslip Credit Note is checked or not.
80 -
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!"
85 -
86   I want to generate a payslip from Payslip run.
87 -
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
92 -
93   I create record for generating the payslip for this Payslip run.
94 -
95   !record {model: hr.payslip.employees, id: hr_payslip_employees0}:
96     employee_ids:
97       - hr_employee_richard0
98 -
99   I generate the payslip by clicking on Generat button wizard.
100 -
101   !python {model: hr.payslip.employees}: |
102      self.compute_sheet(cr, uid, [ref('hr_payslip_employees0')], context={'active_id': ref('hr_payslip_run_PayslipforEmployee0')})
103 -
104   I open Contribution Register and from there I print the Payslip Lines report.
105 -
106   !record {model: payslip.lines.contribution.register, id: payslip_lines_contribution_register0}:
107     date_from: '2011-09-30'
108     date_to: '2011-09-01'
109 -
110   I print the payslip report
111 -
112   !python {model: hr.payslip}: |
113     import os
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)
119 -
120   I print the payslip details report
121 -
122   !python {model: hr.payslip}: |
123     import os
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)
129 -
130   I print the contribution register report
131 -
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')