From d2ca30caf9d3772c5a646c581f8909b2bd11b183 Mon Sep 17 00:00:00 2001 From: mtr Date: Mon, 4 Apr 2011 12:14:53 +0530 Subject: [PATCH] [IMP] hr_payroll:improved code to calculate total_payment for multiple contract bzr revid: mtr@mtr-20110404064453-sd7a9pecamnt80fn --- addons/hr_payroll/hr_payroll.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 7df48eef52f..66b09d8a900 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -745,9 +745,11 @@ class hr_payslip(osv.osv): continue net_allow = 0.0 net_deduct = 0.0 + all_basic = 0.0 for contract in contracts: sal_structure = [] rules = [] + all_basic += contract.wage if contract.struct_id.id: sal_structure = self._get_parent_structure(cr, uid, [contract.struct_id.id], context=context) for struct in sal_structure: @@ -997,7 +999,7 @@ class hr_payslip(osv.osv): net_id = salary_rule_pool.search(cr, uid, [('code', '=', 'NET')]) for line in salary_rule_pool.browse(cr, uid, net_id, context=context): - dic = {'basic': amt, 'allowance': net_allow, 'deduction': net_deduct} + dic = {'basic': all_basic, 'allowance': net_allow, 'deduction': net_deduct} exec line.python_compute in dic tot = dic['total'] vals = { @@ -1089,6 +1091,7 @@ class hr_payslip(osv.osv): lines = [] rules = [] sal_structure = [] + all_basic += contract.wage if contract.struct_id.id: sal_structure = self._get_parent_structure(cr, uid, [contract.struct_id.id], context=context) for struct in sal_structure: @@ -1216,7 +1219,6 @@ class hr_payslip(osv.osv): update['value']['line_ids'].append(vals) basic = contract.wage - all_basic += basic final_total += basic + total # number = sequence_obj.get(cr, uid, 'salary.slip') # update['value'].update({ @@ -1356,7 +1358,7 @@ class hr_payslip(osv.osv): net_id = salary_rule_pool.search(cr, uid, [('code', '=', 'NET')]) for line in salary_rule_pool.browse(cr, uid, net_id, context=context): - dic = {'basic': amt, 'allowance': net_allow, 'deduction': net_deduct} + dic = {'basic': all_basic, 'allowance': net_allow, 'deduction': net_deduct} exec line.python_compute in dic tot = dic['total'] vals = {