Odoo Help

Welcome!

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.

0

readonly attrs not working in openerp7

By
Lady Sharmane Udtuhan
on 10/8/13, 1:45 AM 2,072 views

..Im not sure if it is a bug or I'm just wrong in my code but it is not working for me.. All i want to do is when my state is 'final' the group will be readonly, but it is not working

* attrs="{'readonly': [('state','=','final')]}"*

and when i use this code:

* states="{'final':[('readonly',True)]}"*

instead of being readonly , the group becomes invisible..

Can anyone know to fix this?? Thanks in advance :D

0
Vikram
On 10/8/13, 2:47 AM

Please try this one, redefine the state field in .py file with

readonly=False, states={'final':[('readonly',True)]},

thanks.

There is an error Error: Unknown field state in domain [["state","in",["final"]]]

Lady Sharmane Udtuhan
on 10/8/13, 3:19 AM

Add <field name="state" invisible="1"> in the view where you are using above code you describe.

Hiral Patel (hip)
on 10/8/13, 3:34 AM

Thanks for help.. I got it now.. but I'm wondering can i do this in .xml, because if I use this in .py I need to put readonly=False, states={'final':[('readonly',True)]}, in all of my fields and it is to many.. Technically when my state becomes final the whole form should be in readonly.. Thanks

Lady Sharmane Udtuhan
on 10/8/13, 3:50 AM

You can do it in xml but here also you need to add attrs like: attrs="{'readonly':[('state','=','final')]}" in all fields you want to make readonly.

Hiral Patel (hip)
on 10/8/13, 4:13 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

0 follower(s)

Stats

Asked: 10/8/13, 1:45 AM
Seen: 2072 times
Last updated: 3/16/15, 8:10 AM