From 473a1541e1737f29c5ff9c91cbfc1337bda2550d Mon Sep 17 00:00:00 2001 From: mtr Date: Fri, 11 Mar 2011 14:27:40 +0530 Subject: [PATCH] [IMP] hr_payroll:added code in onchange_employee_id if salary structure has parent_id bzr revid: mtr@mtr-20110311085740-gkz19qlnpt38gowc --- addons/hr_payroll/hr_payroll.py | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index ad9761b7b85..fd85d272b78 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -917,19 +917,40 @@ class hr_payslip(osv.osv): return update contract = employee_id.contract_id + sal_structure = [] function = contract.struct_id.id + sal_structure.append(function) + if contract.struct_id.parent_id: + sal_structure.append(contract.struct_id.parent_id.id) + for s in sal_structure: + sal_struct = func_pool.read(cr, uid, s, ['parent_id'], context=context) + if sal_struct['parent_id']: + structure_id = sal_struct['parent_id'][0] + while(sal_struct['parent_id']): + if structure_id: + sal_struct = func_pool.browse(cr, uid, structure_id, context=context) + for struct_line in [sal_struct]: + structure_id = struct_line.parent_id + if structure_id: + sal_structure.append(structure_id.id) + lines = [] + rules = [] if function: - func = func_pool.read(cr, uid, function, ['rule_ids'], context=context) - lines = salary_rule_pool.browse(cr, uid, func['rule_ids'], context=context) + for struct in sal_structure: + func = func_pool.read(cr, uid, struct, ['rule_ids'], context=context) + lines = salary_rule_pool.browse(cr, uid, func['rule_ids'], context=context) + for rul in lines: + rules.append(rul) + ad = [] total = 0.0 obj = {'basic':contract.wage} - for line in lines: + for line in rules: cd = line.code.lower() obj[cd] = line.amount or 0.0 - for line in lines: + for line in rules: if line.category_id.code in ad: continue ad.append(line.category_id.code) @@ -1011,7 +1032,7 @@ class hr_payslip(osv.osv): 'contract_id': contract.id, 'company_id': employee_id.company_id.id }) - + for line in employee_id.line_ids: vals = { 'category_id': line.category_id.id,