1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
view_function = self.env.ref('base.user_groups_view_function', raise_if_not_found=False) if view_function and view_function.exists() and view_function._name == 'ir.ui.view': group_no_one = view_function.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(): # hide groups in categories 'Hidden' and 'Extra' (except for group_no_one) 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': # application name with a selection field field_name = name_selection_groups(gs.ids) xml1.append(E.field(name=field_name, **attrs)) xml1.append(E.newline()) else: # application separator with boolean fields 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: # make the group_no_one invisible in the form view xml2.append(E.field(name=field_name, invisible="1", **attrs)) elif g.classification in ('function_access', 'data_access'): xml2.append(E.field(name=field_name, **attrs)) else: xml2.append(E.field(name=field_name, invisible="1", **attrs))
xml2.append({'class': "o_label_nowrap"}) xml = E.field(E.group(*(xml1), col="2"), E.group(*(xml2), col="4"), 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_function.with_context(lang=None).write({'arch': xml_content, 'arch_fs': False})
|
近期评论