This question has been flagged
3 Replies
22501 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.

https://dl.dropboxusercontent.com/u/42025188/js_number.png

Avatar
Discard
Best Answer

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."),

Avatar
Discard
Author

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?

Author

{'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?

Author

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

Best Answer

change_default:

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).

http://soninaresh.wordpress.com/2012/09/24/change_default-in-openerp/

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

 

Avatar
Discard
Author Best Answer

Hi everyone,

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

https://dl.dropboxusercontent.com/u/42025188/no_error_prompt2.png

Avatar
Discard