根据odoo14中的默认公司更新res用户表单



根据用户的默认公司需要在odoo 14 中的用户表单中隐藏一些组和组类别

某些组必须对特定公司可见,如果一个用户更改了他们的company_id,则该特定公司允许的组应该存在于用户表单中

您可以尝试重写base中res_groups.py中的update_user_groups_view((函数。下面是该函数中用于隐藏组的代码部分。

else:
# application separator with boolean fields
app_name = app.name or 'Other'
xml3.append(E.separator(string=app_name, colspan="4", **attrs))
attrs['attrs'] = user_type_readonly
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
xml3.append(E.field(name=field_name, invisible="1", **attrs))
else:
xml3.append(E.field(name=field_name, **attrs))

您覆盖此函数并在此处插入条件,然后覆盖res_user中的fields_view_get(如(

@api.model
def fields_view_get(self, view_id=None, view_type="form", **kwargs):
if view_type == "form":
self.env["res.groups"].sudo()._update_user_groups_view()
return super(ResUsers, self).fields_view_get(view_id=view_id, view_type=view_type, **kwargs)

最新更新