diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 9ef2b13c53c..6c2713bb41e 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -963,38 +963,40 @@ class hr_payslip(osv.osv): raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ') % (e)) if line.amount_type == 'per': try: - if line.parent_rule_id: - for rul in [line.parent_rule_id]: -# if rul.child_depend: - val = rul.amount * amt - amt = val - value = line.amount * amt - if line.condition_range_min or line.condition_range_max: - if ((value < line.condition_range_min) or (value > line.condition_range_max)): - value = 0.0 + if line.child_depend == False: + if line.parent_rule_id: + for rul in [line.parent_rule_id]: + val = rul.amount * amt + amt = val + value = line.amount * amt + if line.condition_range_min or line.condition_range_max: + if ((value < line.condition_range_min) or (value > line.condition_range_max)): + value = 0.0 + else: + value = value else: value = value - else: - value = value except Exception, e: raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ') % (e)) + elif line.amount_type == 'fix': - if line.parent_rule_id: + if line.child_depend == False: + if line.parent_rule_id: for rul in [line.parent_rule_id]: -# if rul.child_depend: value = value - if line.condition_range_min or line.condition_range_max: - if ((line.amount < line.condition_range_min) or (line.amount > line.condition_range_max)): - value = value + if line.condition_range_min or line.condition_range_max: + if ((line.amount < line.condition_range_min) or (line.amount > line.condition_range_max)): + value = value + else: + value = line.amount else: value = line.amount - else: - value = line.amount elif line.amount_type=='code': localdict = {'basic':amt} exec line.python_code in localdict value = localdict['result'] total += value + vals = { 'category_id': line.category_id.id, 'name': line.name, @@ -1008,12 +1010,18 @@ class hr_payslip(osv.osv): # 'function_id': False, 'base': line.computational_expression } - if line.appears_on_payslip and not line.parent_rule_id: - if line.condition_range_min or line.condition_range_max: - if not ((value < line.condition_range_min) or (value > line.condition_range_max)): - update['value']['line_ids'].append(vals) + if line.appears_on_payslip: + if line.parent_rule_id: + for l in salary_rule_pool.browse(cr, uid, [line.parent_rule_id.id], context=context): + if l.display_child_rules == True: + update['value']['line_ids'].append(vals) else: - update['value']['line_ids'].append(vals) + if line.condition_range_min or line.condition_range_max: + if not ((value < line.condition_range_min) or (value > line.condition_range_max)): + update['value']['line_ids'].append(vals) + else: + update['value']['line_ids'].append(vals) + basic = contract.wage number = sequence_obj.get(cr, uid, 'salary.slip') update['value'].update({ @@ -1120,6 +1128,7 @@ class hr_payslip(osv.osv): 'worked_days': working_day - leave, 'working_days': working_day, }) + return update hr_payslip() @@ -1215,6 +1224,7 @@ class hr_salary_rule(osv.osv): 'active':fields.boolean('Active'), 'python_code': fields.text('Python code'), 'python_compute':fields.text('Python Code'), + 'display_child_rules': fields.boolean('Display Child Rules', help="Used for the display of Child Rules on payslip"), } _defaults = { 'python_compute': '''# basic\n\nresult = basic * 0.10''', diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index 74bc26ac4ef..49dd802f9e0 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -632,6 +632,7 @@ +