[FIX] account_group: Avoid parent_id recursion
Issue: Infinite loop in Trial Balance. Analyze: The infinite loop is due to account_reports.models.account_report.AccountReport.get_account_codes `while group:` loop if a recursion exist in group.parent_id there is an infinite loop. Fix: Ensure the no recursion constrains on parent_id in account_reports. Related task: opw-3665256 closes odoo/odoo#156410 X-original-commit: 0ce8efbc78853876b9768b6500a4998745ecc070 Signed-off-by: Benjamin Hanquin (beha) <beha@odoo.com> Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
@@ -15933,6 +15933,13 @@ msgid ""
|
||||
"move and post it after."
|
||||
msgstr ""
|
||||
|
||||
#. module: account
|
||||
#. odoo-python
|
||||
#: code:addons/account/models/account_account.py:0
|
||||
#, python-format
|
||||
msgid "You cannot create recursive groups."
|
||||
msgstr ""
|
||||
|
||||
#. module: account
|
||||
#. odoo-python
|
||||
#: code:addons/account/models/account_move_line.py:0
|
||||
|
||||
@@ -905,6 +905,11 @@ class AccountGroup(models.Model):
|
||||
del vals['code_prefix_start']
|
||||
return vals
|
||||
|
||||
@api.constrains('parent_id')
|
||||
def _check_parent_not_circular(self):
|
||||
if not self._check_recursion():
|
||||
raise ValidationError(_("You cannot create recursive groups."))
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
groups = super().create([self._sanitize_vals(vals) for vals in vals_list])
|
||||
|
||||
Reference in New Issue
Block a user