[FIX] hr_payroll: prevents maximum recursion depth
When computing a salary sheet, a maximum recursion error could happen if there is a cycle in the rules or in the categories. Add constrains for salary rules and categories. Closes #25405
This commit is contained in:
@@ -6,8 +6,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 11.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-03-16 15:45+0000\n"
|
||||
"PO-Revision-Date: 2018-03-16 15:45+0000\n"
|
||||
"POT-Creation-Date: 2018-06-27 15:42+0000\n"
|
||||
"PO-Revision-Date: 2018-06-27 15:42+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@@ -605,6 +605,18 @@ msgstr ""
|
||||
msgid "Error ! You cannot create a recursive Salary Structure."
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_payroll
|
||||
#: code:addons/hr_payroll/models/hr_salary_rule.py:91
|
||||
#, python-format
|
||||
msgid "Error! You cannot create recursive hierarchy of Salary Rule Category."
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_payroll
|
||||
#: code:addons/hr_payroll/models/hr_salary_rule.py:176
|
||||
#, python-format
|
||||
msgid "Error! You cannot create recursive hierarchy of Salary Rules."
|
||||
msgstr ""
|
||||
|
||||
#. module: hr_payroll
|
||||
#: model:ir.model.fields,help:hr_payroll.field_hr_payslip_line_register_id
|
||||
#: model:ir.model.fields,help:hr_payroll.field_hr_salary_rule_register_id
|
||||
|
||||
@@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user