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.

26 lines
958 B

  1. # coding: utf-8
  2. # Copyright 2014 ABF OSIELL <http://osiell.com>
  3. # Copyright 2017 Opener B.V. <https://opener.amsterdam>
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  5. from lxml import etree
  6. from openerp import api, models
  7. class ResGroups(models.Model):
  8. _inherit = 'res.groups'
  9. @api.model
  10. def update_user_groups_view(self):
  11. """ Make group selection and checkboxes appear readonly when there
  12. are roles on the user """
  13. res = super(ResGroups, self).update_user_groups_view()
  14. view = self.env.ref('base.user_groups_view')
  15. xml = etree.fromstring(view.arch.encode('utf-8'))
  16. for field in xml.findall('field'):
  17. field.attrib['attrs'] = (
  18. "{'readonly': [('role_line_ids', '!=', [])]}")
  19. xml_content = etree.tostring(
  20. xml, pretty_print=True, xml_declaration=True, encoding="utf-8")
  21. view.write({'arch': xml_content})
  22. return res