[FIX] base: prevent deletion of group linked to settings field
before this commit, if tries to delete a user group which is linked with a field in settings, ie, via implied_groups in res.config.settings or used in the field group, there is no restriction and user group will get deleted. and then if user tries to access any settings page the traceback will be shown to user. after this commit, on deleting any user group which is linked with a field in res.config.settings, a validation message will be shown to the user that the group cannot be deleted as it is linked with a settings field. closes odoo/odoo#123905 X-original-commit: ef3dfd02012e16c88789137f5eb0ec49b22f4df8 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
This commit is contained in:
@@ -31065,6 +31065,12 @@ msgstr ""
|
||||
|
||||
#. module: base
|
||||
#. odoo-python
|
||||
#: code:addons/base/models/res_users.py:0
|
||||
#, python-format
|
||||
msgid "You cannot delete a group linked with a settings field."
|
||||
msgstr ""
|
||||
|
||||
#. module: base
|
||||
#: code:addons/base/models/res_partner.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
|
||||
@@ -153,6 +153,13 @@ class Groups(models.Model):
|
||||
def _check_one_user_type(self):
|
||||
self.users._check_one_user_type()
|
||||
|
||||
@api.ondelete(at_uninstall=False)
|
||||
def _unlink_except_settings_group(self):
|
||||
classified = self.env['res.config.settings']._get_classified_fields()
|
||||
for _name, _groups, implied_group in classified['group']:
|
||||
if implied_group.id in self.ids:
|
||||
raise ValidationError(_('You cannot delete a group linked with a settings field.'))
|
||||
|
||||
@api.depends('category_id.name', 'name')
|
||||
def _compute_full_name(self):
|
||||
# Important: value must be stored in environment of group, not group1!
|
||||
|
||||
Reference in New Issue
Block a user