Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
4287 มุมมอง

Greetings!

In odoo 13 the model sale.order has this definition for this field

But if I want to make this field readonly I have several ways:


  1. Add attrs readonly in view

  2. Overwrite the definition by rewriting it again (payment_term_id = fields.Many2o....
    I can use states={'draft': [('readonly', False)]} or I can use required=True directly

I wonder if there is another way to resolve this, for example rewrite some method that tries to get the field attributes for the view. Or something like that.

Kind regards.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Luis,  as you said there are several ways to do that, consider the following expression:

<field name="payment_term_id" attrs="{'readonly': [('state', '=', 'cancel')]}" />

This attribute will change depending on the state of the sales order and it will be checked on the fly.

Hope it helps you.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
พ.ค. 20
2936
1
มิ.ย. 23
2438
Change the string of an inherited field แก้ไขแล้ว
7
ธ.ค. 23
26179
1
ม.ค. 23
2655
4
ต.ค. 22
18546