2 I test the "Payslip" in order to check the hr_payroll_account module in OpenERP
6 !record {model: res.partner.bank, id: res_partner_bank_0}:
7 acc_number: '987654321'
8 partner_id: base.res_partner_desertic_hispafuentes
13 I create a new employee "John"
15 !record {model: hr.employee, id: hr_employee_john}:
16 address_home_id: base.res_partner_address_2
17 address_id: base.res_partner_address_9
18 birthday: '1984-05-01'
21 department_id: hr.dep_it
25 bank_account_id: res_partner_bank_0
28 I create a salary structure for 'Software Developer'
30 !record {model: hr.payroll.structure, id: hr_payroll_structure_softwaredeveloper}:
31 name: Salary Structure for Software Developer
33 company_id: base.main_company
34 parent_id: hr_payroll.structure_base
36 - hr_payroll.hr_salary_rule_houserentallowance1
37 - hr_payroll.hr_salary_rule_convanceallowance1
38 - hr_payroll.hr_salary_rule_professionaltax1
39 - hr_payroll.hr_salary_rule_providentfund1
40 - hr_payroll.hr_salary_rule_meal_voucher
41 - hr_payroll.hr_salary_rule_sales_commission
43 I create a contract for "John"
45 !record {model: hr.contract, id: hr_contract_john}:
46 date_end: !eval "'%s-%s-%s' %(datetime.now().year+1,datetime.now().month,datetime.now().day)"
47 date_start: !eval time.strftime('%Y-%m-%d')
48 name: Contract for John
50 type_id: hr_contract.hr_contract_type_emp
51 employee_id: hr_employee_john
52 struct_id: hr_payroll_structure_softwaredeveloper
53 working_hours: resource.timesheet_group1
57 !record {model: hr.payslip, id: hr_payslip_0}:
58 employee_id: hr_employee_john
59 journal_id: account.expenses_journal
61 The selection of an employee fills the contract, structure, worked days and input data fields
63 !python {model: hr.payslip}: |
65 from datetime import datetime
66 from dateutil import relativedelta
67 date_from = time.strftime('%Y-%m-01')
68 worked_days_obj = self.pool.get('hr.payslip.worked_days')
69 date_to = str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10]
70 res = self.onchange_employee_id(cr, uid, [], date_from, date_to, ref("hr_employee_john"), False, None)
72 'struct_id': res['value']['struct_id'],
73 'contract_id': res['value']['contract_id'],
74 'name': res['value']['name'],
76 vals['worked_days_line_ids'] = [(0,0,i) for i in res['value']['worked_days_line_ids']]
77 vals['input_line_ids'] = [(0,0,i) for i in res['value']['input_line_ids']]
78 self.write(cr, uid, ref("hr_payslip_0"), vals)
80 I assign the amount to Input data
82 !python {model: hr.payslip.input}: |
83 ids = self.search(cr, uid, [('payslip_id', '=', ref("hr_payslip_0"))])
84 self.write(cr, uid, ids, {'amount': 5.0})
86 I verify the payslip is in draft state
88 !python {model: hr.payslip}: |
89 from tools.translate import _
90 payslip_brw=self.browse(cr, uid, ref("hr_payslip_0"))
91 assert(payslip_brw.state == 'draft'), _('State not changed!')
93 I click on "Compute Sheet" button
95 !python {model: hr.payslip}: |
96 self.compute_sheet(cr, uid, [ref("hr_payslip_0")], {"lang": "en_US", "tz": False,
97 "active_model": "ir.ui.menu", "department_id": False, "active_ids": [ref("hr_payroll.menu_department_tree")],
98 "section_id": False, "active_id": ref("hr_payroll.menu_department_tree"),
101 Then I click on the "Confirm" button
103 !workflow {model: hr.payslip, action: hr_verify_sheet, ref: hr_payslip_0}
105 I verify that the Accounting Entries are created
107 !python {model: hr.payslip}: |
108 payslip = self.browse(cr, uid, ref("hr_payslip_0"))
109 assert payslip.move_id, "Accounting Entries has not been created"
111 I verify that the payslip is in done state
113 !python {model: hr.payslip}: |
114 from tools.translate import _
115 payslip_brw=self.browse(cr, uid, ref("hr_payslip_0"))
116 assert(payslip_brw.state == 'done'), _('State not changed!')