跳至内容
菜单
此问题已终结
3 回复
24171 查看

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

形象
丢弃
最佳答案

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?

编写者

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

编写者

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

最佳答案

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

 

形象
丢弃
编写者 最佳答案

Hi everyone,

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

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

形象
丢弃
相关帖文 回复 查看 活动
2
10月 17
5880
0
5月 16
3703
3
8月 15
11873
1
3月 15
6255
1
11月 23
2043