Odoo Help


This community 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.


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

Ajeng Shilvie
on 2/3/15, 2:52 AM 913 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 (MK)
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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


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