2010-07-06 09:07:09 +00:00
|
|
|
-
|
2011-06-06 13:01:57 +00:00
|
|
|
I test the 'Payslip' in order to check the hr_payroll module in OpenERP
|
2010-07-06 09:07:09 +00:00
|
|
|
-
|
|
|
|
I create a new employee “Richard”
|
2010-07-30 08:59:35 +00:00
|
|
|
-
|
2010-07-06 09:07:09 +00:00
|
|
|
!record {model: hr.employee, id: hr_employee_richard0}:
|
|
|
|
address_home_id: base.res_partner_address_2
|
|
|
|
address_id: base.res_partner_address_9
|
|
|
|
birthday: '1984-05-01'
|
|
|
|
children: 0.0
|
|
|
|
country_id: base.in
|
|
|
|
department_id: hr.dep_it
|
|
|
|
gender: male
|
2011-06-06 13:01:57 +00:00
|
|
|
marital: single
|
2010-07-06 09:07:09 +00:00
|
|
|
name: Richard
|
|
|
|
vehicle_distance: 0.0
|
|
|
|
-
|
2011-06-06 13:01:57 +00:00
|
|
|
I create a salary structure for 'Software Developer'
|
2010-07-06 09:07:09 +00:00
|
|
|
-
|
2011-06-06 13:01:57 +00:00
|
|
|
!record {model: hr.payroll.structure, id: hr_payroll_structure_softwaredeveloper}:
|
|
|
|
name: Salary Structure for Software Developer
|
2010-07-06 09:07:09 +00:00
|
|
|
code: SD
|
2011-06-06 13:01:57 +00:00
|
|
|
company_id: base.main_company
|
|
|
|
parent_id: structure_base
|
|
|
|
rule_ids:
|
|
|
|
- hr_payslip_line_houserantallowance1
|
|
|
|
- hr_payslip_line_convanceallowance1
|
|
|
|
- hr_payslip_line_professionaltax1
|
|
|
|
- hr_payslip_line_providentfund1
|
|
|
|
- hr_salary_rule_meal_voucher
|
|
|
|
- hr_salary_rule_sales_commission
|
|
|
|
-
|
|
|
|
I create a contract for 'Richard'
|
|
|
|
-
|
|
|
|
!record {model: hr.contract, id: hr_contract_richard}:
|
|
|
|
date_end: !eval "'%s-%s-%s' %(datetime.now().year+1,datetime.now().month,datetime.now().day)"
|
|
|
|
date_start: !eval time.strftime('%Y-%m-%d')
|
|
|
|
name: Contract for Richard
|
|
|
|
wage: 5000.0
|
|
|
|
type_id: hr_contract.hr_contract_type_emp
|
|
|
|
employee_id: hr_employee_richard0
|
|
|
|
struct_id: hr_payroll_structure_softwaredeveloper
|
|
|
|
working_hours: resource.timesheet_group1
|
|
|
|
-
|
|
|
|
I create a Payslip
|
2010-07-30 08:59:35 +00:00
|
|
|
-
|
2010-07-06 09:07:09 +00:00
|
|
|
!record {model: hr.payslip, id: hr_payslip_0}:
|
|
|
|
employee_id: hr_payroll.hr_employee_richard0
|
2010-07-30 08:59:35 +00:00
|
|
|
-
|
2011-06-07 05:59:51 +00:00
|
|
|
The selection of an employee fills the contract, structure, worked days and input data fields
|
2010-07-30 08:59:35 +00:00
|
|
|
-
|
2010-07-06 09:07:09 +00:00
|
|
|
!python {model: hr.payslip}: |
|
2011-06-06 13:01:57 +00:00
|
|
|
import time
|
|
|
|
from datetime import datetime
|
|
|
|
from dateutil import relativedelta
|
|
|
|
date_from = time.strftime('%Y-%m-01')
|
|
|
|
worked_days_obj = self.pool.get('hr.payslip.worked_days')
|
|
|
|
date_to = str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10]
|
2011-06-07 05:59:51 +00:00
|
|
|
emp_id = self.pool.get('hr.employee').search(cr, uid, [('id', '=', ref("hr_employee_richard0"))])
|
2011-06-06 13:01:57 +00:00
|
|
|
res = self.onchange_employee_id(cr, uid, [], date_from, date_to, ref("hr_employee_richard0"), False, None)
|
|
|
|
vals = {
|
2011-06-07 05:59:51 +00:00
|
|
|
'employee_id': emp_id[0],
|
2011-06-06 13:01:57 +00:00
|
|
|
'struct_id': res['value']['struct_id'],
|
|
|
|
'contract_id': res['value']['contract_id'],
|
|
|
|
'name': res['value']['name'],
|
|
|
|
}
|
|
|
|
vals['worked_days_line_ids'] = [(0,0,i) for i in res['value']['worked_days_line_ids']]
|
|
|
|
vals['input_line_ids'] = [(0,0,i) for i in res['value']['input_line_ids']]
|
|
|
|
self.write(cr, uid, ref("hr_payslip_0"), vals)
|
|
|
|
-
|
|
|
|
I assign the amount to Input data
|
|
|
|
-
|
|
|
|
!python {model: hr.payslip.input}: |
|
|
|
|
ids = self.search(cr, uid, [('payslip_id', '=', ref("hr_payslip_0"))])
|
|
|
|
self.write(cr, uid, ids, {'amount': 5.0})
|
|
|
|
-
|
|
|
|
I verify the payslip is in draft state
|
2010-07-06 09:07:09 +00:00
|
|
|
-
|
|
|
|
!python {model: hr.payslip}: |
|
|
|
|
from tools.translate import _
|
|
|
|
payslip_brw=self.browse(cr, uid, ref("hr_payslip_0"))
|
2010-07-30 08:59:35 +00:00
|
|
|
assert(payslip_brw.state == 'draft'), _('State not changed!')
|
|
|
|
-
|
2011-06-06 13:01:57 +00:00
|
|
|
I click on 'Compute Sheet' button
|
2010-07-06 09:07:09 +00:00
|
|
|
-
|
|
|
|
!python {model: hr.payslip}: |
|
2011-06-06 13:01:57 +00:00
|
|
|
self.compute_sheet(cr, uid, [ref("hr_payslip_0")], {"lang": "en_US", "tz": False,
|
|
|
|
"active_model": "ir.ui.menu", "department_id": False, "active_ids": [ref("hr_payroll.menu_department_tree")],
|
|
|
|
"section_id": False, "active_id": ref("hr_payroll.menu_department_tree"),
|
|
|
|
})
|
2010-07-30 08:59:35 +00:00
|
|
|
-
|
2011-06-06 13:01:57 +00:00
|
|
|
Then I click on the 'Confirm' button
|
|
|
|
-
|
|
|
|
!workflow {model: hr.payslip, action: hr_verify_sheet, ref: hr_payslip_0}
|
2010-07-06 09:07:09 +00:00
|
|
|
-
|
2011-06-06 13:01:57 +00:00
|
|
|
I verify that the payslip is in done state
|
2010-07-06 09:07:09 +00:00
|
|
|
-
|
|
|
|
!python {model: hr.payslip}: |
|
|
|
|
from tools.translate import _
|
|
|
|
payslip_brw=self.browse(cr, uid, ref("hr_payslip_0"))
|
2011-06-06 13:01:57 +00:00
|
|
|
assert(payslip_brw.state == 'done'), _('State not changed!')
|