summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>2011-04-08 16:55:54 +0200
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>2011-04-08 16:55:54 +0200
commit1042c0c0d6aa00a35cda647db1cd82b6370327a4 (patch)
tree0430b206d37a5a709f7b26929e7f32fc1a3e92a0
parent5cf844c23025466f7394476314ebd8225f7c6d17 (diff)
[FIX] hr_payroll, computation engine: the heads have to be summed recursively
bzr revid: qdp-launchpad@openerp.com-20110408145554-q09v8sud2jf63l3j
-rw-r--r--addons/hr_payroll/hr_payroll.py9
1 files changed, 8 insertions, 1 deletions
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,