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

Hello,

I want to make pricelist_id field in Sales Order readonly for a new_group and pricelist_id is already having a group product.group_product_pricelist for the version 17


I tried in below manner bit raising an error.

                   

               

                

               

                       position="attributes">

                    1

                    dp_sales_price_readonly.group_unit_price_readonly_sales, !product.group_product_pricelist

               


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

Hi,

Hi Megha,

To make the pricelist_id field in the Sales Order read-only for a specific group, you can use the attrs attribute to conditionally set the readonly property based on the user's group. Here's how you can achieve this:

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

    <field name="name">sale.order.form.inherited</field>

    <field name="model">sale.order</field>

    <field name="inherit_id" ref="sale.view_order_form"/>

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

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

            <attribute name="attrs">{'readonly': [('group_id', 'not in', [ref('module_name.new_group')])]}</attribute>

        </xpath>

    </field>

</record>

This XML code will set the pricelist_id field as read-only for users who are not in the new_group. Replace module_name.new_group with the actual XML ID of your group new_group.

Make sure to replace 'module_name.new_group' with the appropriate XML ID of your group. Additionally, ensure that your group IDs are correctly defined in your Odoo.


Hope it helpful


Ảnh đại diện
Huỷ bỏ

this is for version 15

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 25
333
1
thg 10 24
1651
1
thg 8 24
1022
1
thg 2 22
4465
9
thg 7 21
62816