From 87ec60d4df67f0f9cb8497d6bf5ef1237549275d Mon Sep 17 00:00:00 2001 From: Harsh Vadodaria Date: Fri, 6 Jul 2018 15:23:58 +0530 Subject: [PATCH] [IMP]: Added Upstream Patch for hr_payroll --- addons/hr_payroll/models/hr_salary_rule.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/hr_payroll/models/hr_salary_rule.py b/addons/hr_payroll/models/hr_salary_rule.py index f651e025..85a99284 100644 --- a/addons/hr_payroll/models/hr_salary_rule.py +++ b/addons/hr_payroll/models/hr_salary_rule.py @@ -85,6 +85,11 @@ class HrSalaryRuleCategory(models.Model): company_id = fields.Many2one('res.company', string='Company', default=lambda self: self.env['res.company']._company_default_get()) + @api.constrains('parent_id') + def _check_parent_id(self): + if not self._check_recursion(): + raise ValidationError(_('Error! You cannot create recursive hierarchy of Salary Rule Category.')) + class HrSalaryRule(models.Model): _name = 'hr.salary.rule' @@ -165,6 +170,11 @@ class HrSalaryRule(models.Model): input_ids = fields.One2many('hr.rule.input', 'input_id', string='Inputs', copy=True) note = fields.Text(string='Description') + @api.constrains('parent_rule_id') + def _check_parent_rule_id(self): + if not self._check_recursion(parent='parent_rule_id'): + raise ValidationError(_('Error! You cannot create recursive hierarchy of Salary Rules.')) + @api.multi def _recursive_search_of_rules(self): """