This question has been flagged

Odoo 13 on Odoo.sh:


How can I allow a specific user (or group) edit access on only ONE FIELD on the Product screen?

I need this user to be able to read and see everything on the screen, but they can only edit one field.


See screenshot: https://pasteboard.co/JwyYaqE.png

Avatar
Discard
Best Answer

Hi Russ Schneider,

You can do this by using group.

Just you need to inherit of product form view and need to mention group_id and then you can make field readonly and editable.

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

    <field name = "name"> product.template.cancel.form.mods </field>

    <field name = "model"> product.product </field>

    <field name = "inherit_id" ref = "product.product_normal_form_view" />

    <field name = "groups_id" eval = "[(6, 0, [ref ('module_name.group_id')])]" />

    <field name = "arch" type = "xml">

        <xpath expr = "// field [@ name = 'your_field_name']" position = "attributes">

            <attribute name = "readonly"> 0 </attribute>

        </xpath>

        <xpath expr = "// field [@ name = 'your_field_name']" position = "attributes">

            <attribute name = "readonly"> 1 </attribute>

        </xpath>

    </field>

</record>

Thanks ...

For more information Contact us:- https: //kanakinfosystems.com/odoo-development-services

Avatar
Discard
Author

This IS a correct answer. It works. But I was hoping to find a more elegant solution that didn't involve over 100 xpath declarations, hardcoded. :)

Does this works in odoo16?

groups_id is allowed only for new view and not for inherited views in v16.