Reputation: 37
I want to hide unnecessary contents in tab Access Rights when Create New User. Access Rights tab is located in res_users_view. Here's the original code:
<page name="access_rights" string="Access Rights">
<group string="Multi Companies" attrs="{'invisible': [('companies_count', '<=', 1)]}">
<field string="Allowed Companies" name="company_ids" widget="many2many_tags"/>
<field string="Current Company" name="company_id" context="{'user_preference': 0}"/>
<field string="Companies count" name="companies_count" invisible="1"/>
</group>
<field name="groups_id"/>
</page>
What I want to hide is a group of fields named "sel_groups_xx" and "in_group_yy" (xx and yy are numbers). Here's my code (I tried to hide 1 field first):
<record id="view_users_form_inherit" model="ir.ui.view">
<field name="name">res.users.form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form" />
<field name="arch" type="xml">
<xpath expr="//form/sheet/notebook/page[@name='access_rights']/field[@name='groups_id']" position="replace">
<field name="sel_groups_24" invisible="1"/>
</xpath>
</field>
</record>
However, it gave back an error message.
ParseError: "Error while validating constraint
Element 'field name="groups_id"' cannot be located in parent view
Error context: View
res.users.groups
[view_id: 155, xml_id: base.user_groups_view, model: res.users, parent_id: 152] None" while parsing /home/Documents/odoo/modify/views/users_add_position_view.xml:15
My first question, am I right to assume "sel_groups_xx" and "in_groups_yy" are inside "groups_id" ? if the fields are indeed located in "groups_id", how can I access them?
Upvotes: 1
Views: 704
Reputation: 2754
"sel_groups_xx" and "in_groups_yy" are generated fields based on the existing res.groups records in accordance with the user groups_id field. They are created dynamically into the view base.user_groups_view by the res.users method _update_user_groups_view.
If you wanna hide that it, it will be enough to put that view as inactive. No need for your view view_users_form_inherit
Upvotes: 1