Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
4271 Näkymät

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.

Avatar
Hylkää
Paras vastaus

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.

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
0
toukok. 20
2932
1
kesäk. 23
2438
7
jouluk. 23
26177
1
tammik. 23
2652
4
lokak. 22
18538