İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
3049 Görünümler

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

Avatar
Vazgeç
Üretici

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.

Üretici En İyi Yanıt

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.


Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Tem 22
3526
DOMAIN Çözüldü
1
Şub 21
2408
1
Tem 25
2021
2
Tem 25
7533
2
Tem 25
3972