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

Hello,

I have a situation were I want to filter a Category based on a group. So I have the following domain added to the Category field 

    <fields name="categ_id" domain="[('group_id', '=', group_id)]"/>

This works perfect, but now I want to make it that when the group is not selected. That all the lines of the Category fields are shown. I already tried a couple of things, but I can't get it to work.

my last idea is to create an extra boolean field on categ_id that is default False and will always be False. (or can you actually set a constant-field?) and then set the domain to:

['|', ('group_id', '=', group_id), ('false_field','=',group_id)]

But this feels like bad programming, does anybody knows a better way?

Thanks

아바타
취소
작성자

In the mean time i used the last idea I had with the false_field. It works, but I am still thinking if there couldn't be a better way to do this.

작성자 베스트 답변

since there are no better answers, I write the solution that I found for this problem and that solved it for me:

my last idea was to create an extra boolean field on categ_id that is default False and will always be False. (or can you actually set a constant-field?) and then set the domain to filter on that field.

false_field = fields.Boolean("Technical field, do not change or use, should always be FALSE, I know, shitty programming but it works :-)", default=False)

Domain: ['|', ('group_id', '=', group_id), ('false_field','=',group_id)]

This does the job.


아바타
취소
관련 게시물 답글 화면 활동
2
7월 22
3642
DOMAIN 해결 완료
1
2월 21
2471
1
7월 25
2405
2
7월 25
7892
2
7월 25
4300