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

I would like a field to be invisible if a particular many2many field is selected.

Example:

I would like the field to:
<field name = "produce_delay" class = "oe_inline" />

To be invisible if the route_ids field did not have a value of 5 (In my specific case it is the value that represents Manufacturing)

I found this link:
http://ludwiktrammer.github.io/odoo/domain-for-empty-many2many-in-attrs.html

But even applying the rule that appears at the end of the article,
attrs = "{'invisible': [('route_ids', '! =', [(6, False, [5])])]}"

Doesn't it work? Does anyone have any light?
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Gabriel:

Try this. I do not recommend hard coding, but this seems to work for your situation.

NOTE:

a. 1 and 5 are the id's of the "Replenish on Order (MTO)" and "Manufacture" routes. You will need to use the corresponding ids from your environment. Basically, what this is doing is comparing the value of route_ids with the possible combinations of values that are selected for Routes on the screen.

b. The attrs are set on the "label" for the field and the "div" that encloses the field. So you may need to add these conditions to the existing attrs value on the label and div, otherwise the field will be hidden but the label and the div will be visible. 

attrs = "{'invisible': [('route_ids', '!=', (5,)), ('route_ids', '!=', (5,1,))]}"
Ảnh đại diện
Huỷ bỏ
Tác giả

Unfortunately it didn't work either: /

Which screen is this on ?

Tác giả

Hi..

Product template...

U must has the manufacture module and sale managent installed

The route ids its on inventory tab

Hi Gabriel: I have updated by earlier answer based on your clarifications.

Tác giả

Paresh,

Sorry for the delay, I was unavailable for a few days.

It worked perfectly, thanks for the reply!

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

try 'not in' instead of '!='

attrs = "{'invisible': [('test_id', 'not in', [(6, False, ['draft'])])]}"

hope this helps ;)

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

Kiran, thanks for the reply.

There is good news, but, the good news is that now it is really invisible, but no matter what option I select, it does not change the result.

I did two tests using id or using string.


attrs = "{'invisible': [('route_ids', 'not in', [(6, False, [5])])]}"


attrs = "{'invisible': [('route_ids', 'not in', [(6, False, ['Manufacture'])])]}}"


Neither one nor the other unfortunately worked

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 24
7790
1
thg 9 23
2448
7
thg 7 18
20927
2
thg 7 17
3473
0
thg 11 22
80