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 can I set Required Field by Condition

Ken Tong
on 9/22/14, 4:11 AM 4,204 views

Dear All,

I need to set the required field "enable" only if the STATE is changing from READY TO MAINTENANCE to DONE.

Any help is highly appreciated. Kindly refer below attached.




| 5 7 7
Bangalore, India
On 9/22/14, 4:13 AM

Hi Ken, you can user xml attribute called attrs

attrs = "{'readonly':[('state','in',('your_state'))]}"

or you can use in field property

 fields.many2one('res.partner', 'Invoice Address', readonly=True, required=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="Invoice address for current sales order."),

Hi Maniganda, I have set it in the field properties and not XML. {'required':[('state','in',('ready'))]} But the field does not give an error like "this field is required." I am trying to do it in field properties because it is a custom field and i do not wan to modify too much on the xml code itself. The field is not prompting error when i perform next action, it just stay in the same page. any idea?

Ken Tong
on 9/22/14, 5:04 AM

{'readonly':[('state','in',('ready'))],'required':true} This consist of two requirements, required and read only. There might be some syntax error. When i seperate this, i get it correct. Is there something wrong with this attrs?

Ken Tong
on 9/24/14, 11:26 AM

I found that the error message is not prompting out when i am not in editable state. https://dl.dropboxusercontent.com/u/42025188/no_error_prompt.png

Ken Tong
on 9/24/14, 11:39 AM
Ken Tong
On 10/2/14, 3:01 AM

Hi everyone,

Encountered the issue of error not prompt. Kindly refer to the attached.



Med Said BARA

--Med Said BARA--
| 5 5 7
--Med Said BARA--
Med Said BARA
On 9/25/14, 10:21 AM


Whether or not the user can define default values on other fields depending on the value of this field. Those default values need to be defined in the ir.values table.


I think the simplest way to do it is by using the field attribute "change_default" (https://doc.odoo.com/6.0/developer/2_5_Objects_Fields_Methods/openerp_fields/#fields-introduction).


But due to the lack of documentation, i can't understand, how we can use it !!!


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

2 follower(s)


Asked: 9/22/14, 4:11 AM
Seen: 4204 times
Last updated: 3/16/15, 8:10 AM