I have a many2many field in purchase_order_line, i want to make to make that field as readonly on purchase state only
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Hi
You can use attribute as readonly for make it as readonly
Try with following code
<record id="purchase_orderline_form" model="ir.ui.view">
<field name="name">sale.orderline.form</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="//notebook/page[@name='products']/field[@name='order_line']/tree/field[@name='name']"
position="before">
<field name="product_ids" optional="hide" string="Discount" widget="many2many_tags"
attrs="{'readonly':[('state','=','draft')]}"
/>
</xpath>
</field>
</record>
where product_ids is the many2many field
Regards
Hi,
Python and an XML file can be used to make fields read-only based on states.
Using Python:
We can add attributes to the field which need to be hidden.
field_name = fields.field_type( string = ‘Field Name’, states={‘draft’ : [(‘readonly’, True)]})
Using XML:
We can use attrs to make the field read-only
<field name="field_name" string="Field Name" widget="many2many_tags" attrs="{'readonly':[('state','=','draft')]}"/>
Regards
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký