Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
3031 Vizualizări

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

Imagine profil
Abandonează
Autor

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.

Autor Cel mai bun răspuns

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.


Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
iul. 22
3503
DOMAIN Rezolvat
1
feb. 21
2385
1
iul. 25
1892
2
iul. 25
7434
2
iul. 25
3873