Odoo Help


How can I set Required Field by Condition

Ken Tong
on 9/22/14, 4:11 AM 9,178 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.





| 6 8 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 !!!


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

2 follower(s)


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