3

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 ?

ReiiYuki
  • 365
  • 5
  • 19

2 Answers2

4

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>
ReiiYuki
  • 365
  • 5
  • 19
0

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.

Praveen
  • 1
  • 2
  • 1
    Welcome to Stack Overflow _ Your answer looks more like a follow-up question _ Perhaps you would be better off asking a seperate question of your own? Please take a moment to visit SO Help Center and look at the sections on 'Asking' & 'Answering' >>> https://stackoverflow.com/help – inputforcolor Oct 22 '19 at 12:22