Odoo Help


how to make field readonly in edit mode ? [SOLVED]

Ajeng Shilvie
on 2/3/15, 2:52 AM 2,320 views

I have custom field ,  i want to make it readonly in edit mode if my custom one2many filled with some record . 

here's my xml code

                 <field name="branch_id" attrs="{'readonly': ['|',('penerimaan_line','=',True),('state','!=','draft')]}" required="1"/>

it didn't work ..









| 5 3 6
Jakarta, Indonesia
On 2/3/15, 10:57 AM

Try this: <field name="branch_id" attrs="{'readonly': [('id', '>', 0)]}" required="1"/>.  You need to first define the id field (it's an integer field) and put it in the view.


Sorry I misread your question, it should be: <field name="branch_id" attrs="{'readonly': ['|',('penerimaan_line','&lt;&gt;',[]), ('state','!=','draft')]}" required="1"/>,

Thanks ivan , i'll try it

Ajeng Shilvie
on 2/3/15, 9:55 PM

it works , Thanks Ivan

Ajeng Shilvie
on 2/3/15, 9:58 PM
Mohit Kotak
On 2/3/15, 4:22 AM

Hello Ajeng Shilvie,

try to use this code.


i already use it , it didn't work

Ajeng Shilvie
on 2/3/15, 7:31 AM
Souleyman Rapaya
On 2/3/15, 4:11 AM

Try this one <field name="branch_id" attrs="{'readonly': ['|',('penerimaan_line','&lt;&gt;',False),('state','!=','draft')]}" required="1"/>

it didn't work , my fields always readonly even in draft state

Ajeng Shilvie
on 2/3/15, 7:31 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 2/3/15, 2:52 AM
Seen: 2320 times
Last updated: 3/16/15, 8:10 AM