You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.5 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # This file is part of reset_user_access_right,
  5. # an Odoo module.
  6. #
  7. # Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
  8. #
  9. # reset_user_access_right is free software:
  10. # you can redistribute it and/or modify it under the terms of the GNU
  11. # Affero General Public License as published by the Free Software
  12. # Foundation,either version 3 of the License, or (at your option) any
  13. # later version.
  14. #
  15. # reset_user_access_right is distributed
  16. # in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
  17. # even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  18. # PURPOSE. See the GNU Affero General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU Affero General Public License
  21. # along with reset_user_access_right.
  22. # If not, see <http://www.gnu.org/licenses/>.
  23. #
  24. ##############################################################################
  25. from openerp import models, api, exceptions, _
  26. from openerp.tools import SUPERUSER_ID
  27. class ResUsers(models.Model):
  28. _inherit = 'res.users'
  29. @api.multi
  30. def reset_access_right(self):
  31. self.ensure_one()
  32. if self.id == SUPERUSER_ID:
  33. raise exceptions.Warning(_("It's not possible to reset "
  34. "access right for Admin"))
  35. default_groups_ids = self._get_group()
  36. self.groups_id = [(6, 0, default_groups_ids)]