diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 76907f82b31..9ef2b13c53c 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -192,7 +192,6 @@ class payroll_register(osv.osv): slip_line_pool.create(cr, uid, line, context=context) data['value'].pop('line_ids') slip_pool.write(cr, uid, [slip_id], data['value'], context=context) - number = self.pool.get('ir.sequence').get(cr, uid, 'salary.register') return self.write(cr, uid, ids, {'state': 'draft', 'number': number}, context=context) @@ -927,8 +926,10 @@ class hr_payslip(osv.osv): for struct in sal_structure: lines = func_pool.browse(cr, uid, struct, context=context).rule_ids for rl in lines: + if rl.child_ids: + for r in rl.child_ids: + lines.append(r) rules.append(rl) - ad = [] total = 0.0 obj = {'basic': contract.wage} @@ -962,6 +963,11 @@ 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)): @@ -973,6 +979,10 @@ class hr_payslip(osv.osv): except Exception, e: raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ') % (e)) elif line.amount_type == 'fix': + 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 @@ -995,15 +1005,15 @@ class hr_payslip(osv.osv): 'amount': line.amount, 'total': value, 'employee_id': employee_id.id, +# 'function_id': False, 'base': line.computational_expression } - if line.appears_on_payslip: + 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) else: update['value']['line_ids'].append(vals) - basic = contract.wage number = sequence_obj.get(cr, uid, 'salary.slip') update['value'].update({ @@ -1101,7 +1111,6 @@ class hr_payslip(osv.osv): total += value res['total'] = value update['value']['line_ids'].append(res) - basic = basic + total update['value'].update({ 'basic_amount': basic, 'basic_before_leaves': round(basic_before_leaves), @@ -1185,9 +1194,9 @@ class hr_salary_rule(osv.osv): 'appears_on_payslip': fields.boolean('Appears on Payslip', help="Used for the display of rule on payslip"), 'condition_range_min': fields.float('Minimum Range', required=False, help="The minimum amount, applied for this rule."), 'condition_range_max': fields.float('Maximum Range', required=False, help="The maximum amount, applied for this rule."), - 'sal_rule_id':fields.many2one('hr.salary.rule', 'Parent Salary Structure', select=True), + 'parent_rule_id':fields.many2one('hr.salary.rule', 'Parent Salary Rule', select=True), 'child_depend':fields.boolean('Children Rule'), - 'child_ids':fields.one2many('hr.salary.rule', 'sal_rule_id', 'Child Salary Sructure'), + 'child_ids':fields.one2many('hr.salary.rule', 'parent_rule_id', 'Child Salary Rule'), 'company_id':fields.many2one('res.company', 'Company', required=False), 'register_id':fields.property( 'hr.contibution.register', diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index 5a5c1b5b061..74bc26ac4ef 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -648,6 +648,7 @@ hr.salary.rule form + [('parent_rule_id','=',False)]