From 1042c0c0d6aa00a35cda647db1cd82b6370327a4 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Fri, 8 Apr 2011 16:55:54 +0200 Subject: [PATCH] [FIX] hr_payroll, computation engine: the heads have to be summed recursively bzr revid: qdp-launchpad@openerp.com-20110408145554-q09v8sud2jf63l3j --- addons/hr_payroll/hr_payroll.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index a064d7cf3a1..cf3f1e0aeea 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -434,6 +434,12 @@ class hr_payslip(osv.osv): return res def get_payslip_lines(self, cr, uid, contract_ids, payslip_id, context): + def _sum_salary_head(localdict, head, amount): + if head.parent_id: + localdict = _sum_salary_head(localdict, head.parent_id, amount) + localdict['heads'][head.code] = head.code in localdict['heads'] and localdict['heads'][head.code] + amount or amount + return localdict + result = [] blacklist = [] payslip = self.pool.get('hr.payslip').browse(cr, uid, payslip_id, context=context) @@ -452,13 +458,14 @@ class hr_payslip(osv.osv): employee = contract.employee_id localdict.update({'employee': employee, 'contract': contract}) for rule in self.pool.get('hr.salary.rule').browse(cr, uid, sorted_rule_ids, context=context): + localdict['result'] = None #check if the rule can be applied if self.pool.get('hr.salary.rule').satisfy_condition(cr, uid, rule.id, localdict, context=context) and rule.id not in blacklist: amount = self.pool.get('hr.salary.rule').compute_rule(cr, uid, rule.id, localdict, context=context) #set/overwrite the amount computed for this rule in the localdict localdict['rules'][rule.code] = amount #sum the amount for its salary head - localdict['heads'][rule.category_id.code] = rule.category_id.code in localdict['heads'] and localdict['heads'][rule.category_id.code] + amount or amount + localdict = _sum_salary_head(localdict, rule.category_id, amount) vals = { 'name': rule.name, 'code': rule.code,