콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
22249 화면

Hi guys,


I'm having some issues with domains. I know I can use | if I have an or condition. Initially I had the following code:

<field name="gebruik_zorgverlener_adres" attrs="{'invisible': ['|',('gebruik_organisatie_adres','=',True),('gebruik_prive_adres','=',True)]}"/>

<field name="gebruik_organisatie_adres" attrs="{'invisible': ['|',('gebruik_zorgverlener_adres','=',True),('gebruik_prive_adres','=',True)]}"/>

<field name="gebruik_prive_adres" groups="my_module.group_sel_manager" attrs="{'invisible': ['|',('gebruik_zorgverlener_adres','=',True),('gebruik_organisatie_adres','=',True)]}"/

Which is basically saying that when one of those fields is checked on that all others should become invisible. This piece of code works fine!
When I now add a fourth field and add another or condition to all those attrs it will not however. My attempt:

<field name="gebruik_zorgverlener_adres" attrs="{'invisible': ['|',('gebruik_organisatie_adres','=',True),('gebruik_prive_adres','=',True), ('gebruik_maatschappelijke_zetel_adres','=',True)]}"/>

<field name="gebruik_organisatie_adres" attrs="{'invisible': ['|',('gebruik_zorgverlener_adres','=',True),('gebruik_prive_adres','=',True), ('gebruik_maatschappelijke_zetel_adres','=',True)]}"/>

<field name="gebruik_prive_adres" groups="my_module.group_sel_manager" attrs="{'invisible': ['|',('gebruik_zorgverlener_adres','=',True),('gebruik_organisatie_adres','=',True), ('gebruik_maatschappelijke_zetel_adres','=',True)]}"/>

<field name="gebruik_maatschappelijke_zetel_adres" attrs="{'invisible': ['|',('gebruik_zorgverlener_adres','=',True),('gebruik_prive_adres','=',True), ('gebruik_organisatie_adres','=',True)]}"/>

I simply added another field to all those or conditions for all fields but yet this totally fails. When I now test this code not one checkbox will be hidden or shown depending on what I do.
So, what is the correct way to write an or domain so that always only one of those four checkboxes is shown to the user? and is there no other way to write the domain then by calling ALL other field names? There must be a shorter way to code this?

Thank you,
Yenthe

아바타
취소

as "or" operator '|' is a default one, it's not necessary to use it here at all. Try to write all the same domains without any operator, remove all '|'-s, like this:

 attrs="{'invisible': [('gebruik_organisatie_adres','=',True),('gebruik_prive_adres','=',True), ('gebruik_maatschappelijke_zetel_adres','=',True)]}" 

@temur, default operator is AND !

베스트 답변

@Yenthe

Your domains could be get it fixed by adding another '|', like:

<field name="gebruik_zorgverlener_adres" attrs="{'invisible': ['|','|',('gebruik_organisatie_adres','=',True),('gebruik_prive_adres','=',True), ('gebruik_maatschappelijke_zetel_adres','=',True)]}"/>

<field name="gebruik_organisatie_adres" attrs="{'invisible': ['|','|',('gebruik_zorgverlener_adres','=',True),('gebruik_prive_adres','=',True), ('gebruik_maatschappelijke_zetel_adres','=',True)]}"/>

<field name="gebruik_prive_adres" groups="my_module.group_sel_manager" attrs="{'invisible': ['|','|',('gebruik_zorgverlener_adres','=',True),('gebruik_organisatie_adres','=',True), ('gebruik_maatschappelijke_zetel_adres','=',True)]}"/>

<field name="gebruik_maatschappelijke_zetel_adres" attrs="{'invisible': ['|','|',('gebruik_zorgverlener_adres','=',True),('gebruik_prive_adres','=',True), ('gebruik_organisatie_adres','=',True)]}"/>

The thing is that you need to put all the operators in the beginning of the domain to be used like an stack to be matching the domain terms.

아바타
취소
작성자

Thanks a lot Axel, great answer.

관련 게시물 답글 화면 활동
1
2월 16
3702
1
3월 15
16005
4
3월 24
25574
1
11월 20
5008
7
6월 20
6985