diff --git a/odoo/addons/base/i18n/base.pot b/odoo/addons/base/i18n/base.pot index 837ad5bde12..91daff7948e 100644 --- a/odoo/addons/base/i18n/base.pot +++ b/odoo/addons/base/i18n/base.pot @@ -30976,6 +30976,13 @@ msgstr "" msgid "You can not create recursive tags." msgstr "" +#. module: base +#. odoo-python +#: code:addons/base/models/res_users.py:0 +#, python-format +msgid "Deleting the template users is not allowed. Deleting this profile will compromise critical functionalities." +msgstr "" + #. module: base #: model:ir.model.constraint,message:base.constraint_res_users_login_key msgid "You can not have two users with the same login!" diff --git a/odoo/addons/base/models/res_users.py b/odoo/addons/base/models/res_users.py index 5c78215311c..4bd88c1dce8 100644 --- a/odoo/addons/base/models/res_users.py +++ b/odoo/addons/base/models/res_users.py @@ -661,10 +661,14 @@ class Users(models.Model): return res @api.ondelete(at_uninstall=True) - def _unlink_except_superuser(self): + def _unlink_except_master_data(self): + portal_user_template = self.env.ref('base.template_portal_user_id', False) + default_user_template = self.env.ref('base.default_user', False) if SUPERUSER_ID in self.ids: raise UserError(_('You can not remove the admin user as it is used internally for resources created by Odoo (updates, module installation, ...)')) self.clear_caches() + if (portal_user_template and portal_user_template in self) or (default_user_template and default_user_template in self): + raise UserError(_('Deleting the template users is not allowed. Deleting this profile will compromise critical functionalities.')) @api.model def _name_search(self, name, domain=None, operator='ilike', limit=None, order=None):