Reputation: 365
I want to hide edit button based on user group. However I don't want to edit ir.model.access.csv, because some process in my system flow must be able some user group to write the model by code.
Are there some way to hide edit button from some group of user ?
Upvotes: 3
Views: 2696
Reputation: 1
Thanks for your answer, it really helped me.
But when i remove edit/create button for some group (ex: Purchase: User), also the edit/create buttons got removed for the higher groups (ex: Purchase: Manager) of the specified group (ex: Purchase: User).
My case: I've removed edit button for Purhcase: User group, and I see the edit button got removed also for the Purchase: Manager group.
The solution I tried: I have created one more view for Purchase: Manager group and given edit TRUE. So I've created two views for two groups
Looking for better solution to achieve this scenario with single view, as it isn't good to create many views for many groups.
Upvotes: 0
Reputation: 365
I found the answer by myself. I just add the attribute to inherit view like the following code :
<record model="ir.ui.view">
<field name="name">edit_button</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="groups_id" eval="[(4,ref('wongnai_flow.group_edit')),(4, ref('wongnai_flow.group_cs')),(4, ref('wongnai_flow.group_ae')),(4, ref('wongnai_flow.group_csm'))]"/>
<field name="arch" type="xml">
<xpath expr="/form" position="attributes">
<attribute name="create">false</attribute>
<attribute name="edit">false</attribute>
</xpath>
</field>
</record>
Upvotes: 4