Search code examples
pythonpython-2.7odooodoo-10erp

Odoo How to hide edit button based on User Group?


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 ?


Solution

  • 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>