Skip to Content
Menu
This question has been flagged
1 Reply
1799 Views

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
Discard
Author

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.

Author Best Answer

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
Discard
Related Posts Replies Views Activity
2
Jul 22
2487
DOMAIN Solved
1
Feb 21
1652
1
Nov 24
1486
1
Nov 24
1195
2
Sep 24
1047