0

I want to hide the edit and create button on the form view for a specific user I use this code but the button not showing at all i just want to hide buttons just for only group

    <record model="ir.ui.view" id="edit_button_message_">

        <field name="name">edit.button.message.1</field>
        <field name="model">person.message</field>
        <field name="inherit_id" ref="view_parent_message_form"/>
        <field name="groups_id" eval="[(6,0,[ref('person_access')])]"/>
        <field name="arch" type="xml">
            <xpath expr="/form[@string='form_view_string']" position="attributes">
                <attribute name="create">false</attribute>
                <attribute name="edit">false</attribute>
            </xpath>
        </field>
    </record>

and i use this

<form string="form_view_string" edit="false" create="false" >

nothing happened , I use odoo v8

Caludio
  • 135
  • 11

1 Answers1

0

You better create a security access for that group to allow just read to that model, preventing the create, write and unlink actions and those buttons should disappear.

You could create it in xml as it will be only one, like:

<record id="person_message_access" model="ir.model.access">
    <field name="name">edit.button.message.access</field>
    <field name="model_id" ref="person.message"/>
    <field name="group_id" ref="person_access"/>
    <field name="perm_read" eval="1"/>
    <field name="perm_create" eval="0"/>
    <field name="perm_write" eval="0"/>
    <field name="perm_unlink" eval="0"/>
</record>

or you could set it into a field ir.model.access.csv with content like:

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
person_message_access,edit.button.message.access,model_person_message,person_access,1,0,0,0
aekis.dev
  • 2,626
  • 1
  • 12
  • 19
  • I have a button on this interface need to write access so I can't do this – Caludio Oct 10 '18 at 10:13
  • Your button is a custom button, you could define custom groups access for your button, the security rules will affect the create/edit buttons as the records will be readonly, so you could use it as I have sugested. If your button is doing some write or something affected by the new security constraint you could add sudo to the actions calls that require it – aekis.dev Oct 10 '18 at 10:18
  • do you mean perm_write just for this button ? – Caludio Oct 10 '18 at 10:26
  • No. I mean set your button as usual with the groups attribute if it's required. Add the ir.model.access entry for the model to allow just read – aekis.dev Oct 10 '18 at 10:29
  • when i click on this button to mark as read a message he shows me the message of access to this model – Caludio Oct 10 '18 at 10:35
  • That it's not related. The create and edit buttons should have disappeared. The access error should be related to your button method code – aekis.dev Oct 10 '18 at 11:06