Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FW][FIX] account_group: Avoid parent_id recursion #156321

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions addons/account/i18n/account.pot
Original file line number Diff line number Diff line change
Expand Up @@ -15066,6 +15066,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
Expand Down
5 changes: 5 additions & 0 deletions addons/account/models/account_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,11 @@ def _sanitize_vals(self, vals):
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):
res_ids = super(AccountGroup, self).create([self._sanitize_vals(vals) for vals in vals_list])
Expand Down