Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
9490 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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.

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 3 24
1931
1
thg 11 22
3519
1
thg 7 23
1716
5
thg 3 22
14756
1
thg 5 20
4521