[FIX] hr_payroll: avoid infinite recursion
The get_recursive_parent function seemingly depended on the ordering of
the rule_categories recordset which happens to work fine in most cases
because all data first defines the parent before defining the children
rule categories. But if you happen to do it the other way around it
won't work and it will infinitely call itself because:
if rule_categories[0].parent_id:
rule_categories = rule_categories[0].parent_id | rule_categories
won't change the value of rule_categories[0].
opw-673222 (loosely related)
This commit is contained in:
@@ -37,13 +37,16 @@ class payslip_details_report(report_sxw.rml_parse):
|
||||
payslip_line = self.pool.get('hr.payslip.line')
|
||||
rule_cate_obj = self.pool.get('hr.salary.rule.category')
|
||||
|
||||
def get_recursive_parent(rule_categories):
|
||||
if not rule_categories:
|
||||
return []
|
||||
if rule_categories[0].parent_id:
|
||||
rule_categories = rule_categories[0].parent_id | rule_categories
|
||||
get_recursive_parent(rule_categories)
|
||||
return rule_categories
|
||||
def get_recursive_parent(current_rule_category, rule_categories = None):
|
||||
if rule_categories:
|
||||
rule_categories = current_rule_category | rule_categories
|
||||
else:
|
||||
rule_categories = current_rule_category
|
||||
|
||||
if current_rule_category.parent_id:
|
||||
return get_recursive_parent(current_rule_category.parent_id, rule_categories)
|
||||
else:
|
||||
return rule_categories
|
||||
|
||||
res = []
|
||||
result = {}
|
||||
|
||||
Reference in New Issue
Block a user