Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
24242 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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?

Tác giả

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

Tác giả

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

Câu trả lời hay nhất

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

 

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Hi everyone,

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

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 10 17
5908
0
thg 5 16
3711
3
thg 8 15
11919
1
thg 3 15
6297
1
thg 11 23
2087