'Modify the view with xmlid ``base.user_groups_view``, which inherits
the user form view, and introduces the reified group fields.'

@api.model
def _update_user_groups_view(self):

    if self._context.get('install_mode'):
        user_context = self.env['res.users'].context_get()
        self = self.with_context(**user_context)
    view = self.env.ref('base.user_groups_view', raise_if_not_found=False)
    if (view and view.exists() and (view._name == 'ir.ui.view')):
        group_no_one = view.env.ref('base.group_no_one')
        (xml1, xml2) = ([], [])
        xml1.append(E.separator(string=_('Application'), colspan='2'))
        for (app, kind, gs) in self.get_groups_by_application():
            attrs = {}
            if (app.xml_id in ('base.module_category_hidden', 'base.module_category_extra', 'base.module_category_usability')):
                attrs['groups'] = 'base.group_no_one'
            if (kind == 'selection'):
                field_name = name_selection_groups(gs.ids)
                xml1.append(E.field(name=field_name, **attrs))
                xml1.append(E.newline())
            else:
                app_name = (app.name or _('Other'))
                xml2.append(E.separator(string=app_name, colspan='4', **attrs))
                for g in gs:
                    field_name = name_boolean_group(g.id)
                    if (g == group_no_one):
                        xml2.append(E.field(name=field_name, invisible='1', **attrs))
                    else:
                        xml2.append(E.field(name=field_name, **attrs))
        xml2.append({'class': 'o_label_nowrap'})
        xml = E.field(E.group(col='2', *xml1), E.group(col='4', *xml2), name='groups_id', position='replace')
        xml.addprevious(etree.Comment('GENERATED    AUTOMATICALLY    BY    GROUPS'))
        xml_content = etree.tostring(xml, pretty_print=True, xml_declaration=True, encoding='utf-8')
        view.with_context(lang=None).write({'arch': xml_content, 'arch_fs': False})
