I tried like this given below but its not getting what i wanted,what im trying to aquire is if that field(Char) is updated(stored a value) by model B it needs to be readonly and else by other model fields needs to be not readonly :
<field name = 'name' attrs="{'readonly': [('name','=', True)]}"/>
To check if a char field is not set in attrs, compare it to False
, you can find an example in the account partner view.
Example:
<field name='name' attrs="{'readonly': [('name','!=', False)]}"/>
If we use the above definition and try to set the field value, the field value will not be saved because the field is read-only, to avoid that we need to set the force_save
attribute to True
to force Odoo to save the value on the read-only field.
Example:
<field name='name' attrs="{'readonly': [('name','!=', False)]}" force_save='True'/>