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

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.

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

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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 5 20
2965
1
thg 6 23
2458
7
thg 12 23
26238
1
thg 1 23
2682
4
thg 10 22
18598