From 033c24154376972022f6523a356d4648c7146b55 Mon Sep 17 00:00:00 2001 From: mtr Date: Mon, 6 Jun 2011 18:31:57 +0530 Subject: [PATCH] [IMP] hr_payroll: changed yml for payslip as per the changes in hr_payroll module bzr revid: mtr@mtr-20110606130157-bmb3g4t9yslx9n11 --- addons/hr_payroll/__openerp__.py | 2 +- addons/hr_payroll/test/payslip.yml | 160 ++++++++++++----------------- 2 files changed, 67 insertions(+), 95 deletions(-) diff --git a/addons/hr_payroll/__openerp__.py b/addons/hr_payroll/__openerp__.py index 44c0fb93506..454b9a8bb11 100644 --- a/addons/hr_payroll/__openerp__.py +++ b/addons/hr_payroll/__openerp__.py @@ -60,7 +60,7 @@ Generic Payroll system. 'wizard/hr_payroll_year_salary.xml', ], 'test': [ -# 'test/payslip.yml', + 'test/payslip.yml', # 'test/payment_advice.yml', # 'test/payroll_register.yml', # 'test/hr_payroll_report.yml', diff --git a/addons/hr_payroll/test/payslip.yml b/addons/hr_payroll/test/payslip.yml index 56387ee0a98..f9aaae97531 100644 --- a/addons/hr_payroll/test/payslip.yml +++ b/addons/hr_payroll/test/payslip.yml @@ -1,12 +1,11 @@ - - I test the 'Payment Advice' in order to check the hr_payroll in OpenERP + I test the 'Payslip' in order to check the hr_payroll module in OpenERP - - I Create a bank record + I create a bank record - !record {model: res.partner.bank, id: res_partner_bank_0}: acc_number: '987654321' partner_id: base.res_partner_desertic_hispafuentes - sequence: 0.0 name: Fortis state: bank bank: base.res_bank_1 @@ -18,77 +17,79 @@ address_id: base.res_partner_address_9 birthday: '1984-05-01' children: 0.0 - contract_ids: - - advantages_gross: 0.0 - advantages_net: 0.0 - 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: reference - wage: 5000.0 - wage_type_id: hr_contract.hr_contract_monthly_gross - type_id: hr_contract.hr_contract_type_emp country_id: base.in department_id: hr.dep_it gender: male - marital: hr.hr_employee_marital_status_single + marital: single name: Richard bank_account_id: res_partner_bank_0 vehicle_distance: 0.0 - - I create a new payroll structure for software developer + I create a salary structure for 'Software Developer' - - !record {model: hr.payroll.structure, id: hr_payroll_structure_softwaredeveloper0}: + !record {model: hr.payroll.structure, id: hr_payroll_structure_softwaredeveloper}: + name: Salary Structure for Software Developer code: SD - line_ids: - - amount: 0.40000000000000002 - amount_type: per - category_id: hr_payroll.HRA - code: HRA - company_contrib: 0.0 - name: House Rant Allowance - sequence: 5 - total: 0.0 - type: allowance - - amount: 10000.0 - amount_type: fix - category_id: hr_payroll.CA - code: CA - company_contrib: 0.0 - name: Convance Allowance - sequence: 10 - total: 0.0 - type: allowance - - amount: 10000.0 - amount_type: fix - category_id: hr_payroll.PT - code: PT - company_contrib: 0.0 - name: Professional Tax - sequence: 15 - total: 0.0 - type: deduction - - amount: 0.125 - amount_type: per - category_id: hr_payroll.PF - code: PF - company_contrib: 0.0 - name: Provident Fund - sequence: 20 - total: 0.0 - type: deduction - name: Software Developer + 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 employee payslip record + 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 - !record {model: hr.payslip, id: hr_payslip_0}: employee_id: hr_payroll.hr_employee_richard0 - +- + I select employee Richard +- + !python {model: hr.payslip}: | + 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] + res = self.onchange_employee_id(cr, uid, [], date_from, date_to, ref("hr_employee_richard0"), False, None) + vals = { + '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 +- + !python {model: hr.payslip}: | + from tools.translate import _ + payslip_brw=self.browse(cr, uid, ref("hr_payslip_0")) + assert(payslip_brw.state == 'draft'), _('State not changed!') - I click on 'Compute Sheet' button -- - !workflow {model: hr.payslip, action: compute_sheet, ref: hr_payslip_0} -- - just to test - !python {model: hr.payslip}: | self.compute_sheet(cr, uid, [ref("hr_payslip_0")], {"lang": "en_US", "tz": False, @@ -96,42 +97,13 @@ "section_id": False, "active_id": ref("hr_payroll.menu_department_tree"), }) - - I check that the order is now in "Waiting for Verification" state + Then I click on the 'Confirm' button +- + !workflow {model: hr.payslip, action: hr_verify_sheet, ref: hr_payslip_0} +- + I verify that the payslip is in done state - !python {model: hr.payslip}: | from tools.translate import _ payslip_brw=self.browse(cr, uid, ref("hr_payslip_0")) - assert(payslip_brw.state == 'draft'), _('State not changed!') -- - I click on Verify Sheet button. -- - !workflow {model: hr.payslip, action: verify_sheet, ref: hr_payslip_0} -- - I check that the order is in the "Waiting for HR Verification" state -- - !python {model: hr.payslip}: | - from tools.translate import _ - payslip_brw=self.browse(cr, uid, ref("hr_payslip_0")) - assert(payslip_brw.state == 'hr_check'), _('State not changed!') -- - I click on Complete HR Checking button. -- - !workflow {model: hr.payslip, action: final_verify_sheet, ref: hr_payslip_0} -- - I check that the order is in "Confirm Sheet" state. -- - !python {model: hr.payslip}: | - from tools.translate import _ - payslip_brw=self.browse(cr, uid, ref("hr_payslip_0")) - assert(payslip_brw.state == 'confirm'), _('State not changed!') -- - I click on Pay Salary button -- - !workflow {model: hr.payslip, action: process_sheet, ref: hr_payslip_0} -- - I check that the order is in "Paid Salary" state. -- - !python {model: hr.payslip}: | - from tools.translate import _ - payslip_brw=self.browse(cr, uid, ref("hr_payslip_0")) - assert(payslip_brw.state == 'done'), _('State not changed!') + assert(payslip_brw.state == 'done'), _('State not changed!') \ No newline at end of file