diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 8306d1f9fb9..a76daa4e0b0 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -533,10 +533,12 @@ class hr_payslip(osv.osv): 'register_id': rule.register_id.id, 'total': amount, 'employee_id': contract.employee_id.id, + 'quantity': rule.quantity, } else: #blacklist this rule and its children blacklist += [id for id, seq in self.pool.get('hr.salary.rule')._recursive_search_of_rules(cr, uid, [rule], context=context)] + result = [value for code, value in result_dict.items()] return result @@ -641,6 +643,7 @@ class hr_salary_rule(osv.osv): 'name':fields.char('Name', size=256, required=True, readonly=False), 'code':fields.char('Code', size=64, required=True), 'sequence': fields.integer('Sequence', required=True, help='Use to arrange calculation sequence'), + 'quantity': fields.char('Quantity', size=256, help="It is used in computation for percentage and fixed amount.For e.g. A rule for Meal Voucher having fixed amount of 1€ can have its quantity defined in expression like worked_days['WORK100']['number_of_days']."), 'category_id':fields.many2one('hr.salary.head', 'Salary Head', required=True), 'active':fields.boolean('Active', help="If the active field is set to false, it will allow you to hide the salary rule without removing it."), 'appears_on_payslip': fields.boolean('Appears on Payslip', help="Used for the display of rule on payslip"), @@ -712,6 +715,7 @@ result = rules['NET'] > heads['NET'] * 0.10''', 'amount_select': 'fix', 'amount_fix': 0.0, 'amount_percentage': 0.0, + 'quantity': '1', } def _recursive_search_of_rules(self, cr, uid, rule_ids, context=None): @@ -734,12 +738,16 @@ result = rules['NET'] > heads['NET'] * 0.10''', """ rule = self.browse(cr, uid, rule_id, context=context) if rule.amount_select == 'fix': - return rule.amount_fix + try: + return rule.amount_fix * eval(rule.quantity, localdict) + except: + raise osv.except_osv(_('Error'), _('Wrong quantity defined for salary rule %s (%s)')% (rule.name, rule.code)) elif rule.amount_select == 'percentage': try: - return rule.amount_percentage * eval(rule.amount_percentage_base, localdict) / 100 + amount = rule.amount_percentage * eval(rule.amount_percentage_base, localdict) / 100 + return amount * eval(rule.quantity, localdict) except: - raise osv.except_osv(_('Error'), _('Wrong percentage base defined for salary rule %s (%s)')% (rule.name, rule.code)) + raise osv.except_osv(_('Error'), _('Wrong percentage base or quantity defined for salary rule %s (%s)')% (rule.name, rule.code)) else: try: eval(rule.amount_python_compute, localdict, mode='exec', nocopy=True) diff --git a/addons/hr_payroll/hr_payroll_demo.xml b/addons/hr_payroll/hr_payroll_demo.xml index 24736cbb9c2..db903fbabfe 100644 --- a/addons/hr_payroll/hr_payroll_demo.xml +++ b/addons/hr_payroll/hr_payroll_demo.xml @@ -52,8 +52,9 @@ - code - result = worked_days['WORK100']['number_of_days'] * 1 + fix + + worked_days['WORK100']['number_of_days'] MA Meal Voucher diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index ba54ef4c612..c4615ce0cc0 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -528,7 +528,8 @@ - + +