Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.0][BUG] web_advanced_search_x2x - Wrong queries in filters #222

Closed
rafaelbn opened this issue Sep 9, 2015 · 6 comments
Closed

[8.0][BUG] web_advanced_search_x2x - Wrong queries in filters #222

rafaelbn opened this issue Sep 9, 2015 · 6 comments
Assignees
Labels

Comments

@rafaelbn
Copy link
Member

rafaelbn commented Sep 9, 2015

Hi @hbrunn ,

This happends with any query but I will show here only one.

I would like to filter projects which User (uid) is "manager" OR "member" or "follower".

In Odoo core we cannot make this search because the follower are res.partner and not res.user then we need to select Follower -> Is in selection and then in res.parter search User -> the user.

When Odoo creates the filter for this you can only select the res.partner and this is the query:

 ['|',
 '|', ['message_follower_ids', '=', 748], ['members', '=', 52],
 ['user_id', '=', 52],
 ['state', '!=', 'close'], ['state', '!=', 'cancelled']]

When I create the query using advance search it make this wrong:

 [['message_follower_ids.id', 'in', [748]], ['members', '=', 52], ['user_id', '=', 52],
 ['state', '!=', 'close'], ['state', '!=', 'cancelled']]

But it must create this:

 ['|',
 '|', ['message_follower_ids.user_ids', '=', 748], ['members', '=', 52],
 ['user_id', '=', 52],
 ['state', '!=', 'close'], ['state', '!=', 'cancelled']]

Regards

@hbrunn
Copy link
Member

hbrunn commented Sep 11, 2015

the trick is that you need to submit your search after the first selection. If you add conditions in advances search, the terms will be joined by conjunction. If you apply first, and then add the second condition, you'll get the disjunction.

@rafaelbn
Copy link
Member Author

Hi @hbrunn , I leaved this without answer and without solving.

Let's say conditions in Projects.

  • A: is manager (res.user) = 145 results
  • B: is member (res.user) = 15 results
  • C: is follower (we want follower for res.user and not from res.partner) = 149 results

I'm looking (in this example) for A OR B OR C = 154

the trick is that you need to submit your search after the first selection. If you add conditions in advances search, the terms will be joined by conjunction. If you apply first, and then add the second condition, you'll get the disjunction

I'm not able to reproduce this, as you said me. I think I was using you trick and that why I said module has a [BUG]

In Odoo core: (Go to Projects -> projects)

1 - If you want to make disjunction, A OR B, you have to select first condition (A=is manager), add second codition (B=is member), ... and after all conditions are added click in the button Apply.

  • Unfold advance search, select field "Project manager", set "is equal", select your own user
  • Click add condition
  • Select field "Project members", set "is equial", select your own user
  • Click Apply
  • A OR B = 148 results

2 - If you want to make conjunction, A AND B, you have to select first condition (A=is manager), apply, add second codition (B=is member), aplpy, ...

  • Unfold advance search, select field "Project manager", set "is equal", select your own user
  • Click Apply
  • Unfold advance search, select field "Project members", set "is equial", select your own user
  • Click Apply
  • A AND B = 12

Adding module OCA web_advanced_search_x2x

3 - So with my search (I would like to filter projects which User (uid) is "manager" OR "member" OR "follower".) and you comment I did:

  • Case 3.1
    • Point 1 described above (A OR B) +
    • C: Unfold advance search, select field Follower -> Is in selection and then in res.parter search User -> you own user
    • A OR B AND C = 143
  • Case 3.2
    • Unfold advance search, select field Follower -> Is in selection and then in res.parter search User -> you own user
    • Unfold advance search, select field "Project manager", set "is equal", select your own user
    • Click add condition
    • Select field "Project members", set "is equial", select your own user
    • Click Apply
    • A OR B OR C = 53 --> incorrect, here is the BUG

Could you tell me if I'm missing the trick?

Additionaly
  • How can we do/improve this module to be able for excluding a selection?
    • Let's say you have 3 mailing list (m1[rafaelbn], m2[hbrum], m3[rafaelbn,hbrum]) lists and in customers you want to search all customer which are not in mailng list m1. Result now if you make "is in selection"+"mailing list is not equial to m1" is rafaelbn,hbrum (because they are in m2 or m3). But we would like logic for "is not in selection"+
    • We think that we must add the option "is not in selection". Did you not include it for any special reason?

@hbrunn
Copy link
Member

hbrunn commented Nov 20, 2015

@rafaelbn thanks for elaborating, it's fixed in #263

@hbrunn
Copy link
Member

hbrunn commented Nov 20, 2015

About your other questions: negative operators on x2many fields in odoo are nearly never treated the way a user would expect, so implementing it on this level is a recipe for frustration.

For your use cases, use https://github.com/OCA/web/tree/7.0/web_advanced_filters

@hbrunn hbrunn added the 8.0 label Nov 20, 2015
@rafaelbn
Copy link
Member Author

rafaelbn commented Jul 9, 2016

@pedrobaeza @antespi if we want to implement negative operator we must take care on #222 (comment) and maybe discuss with @hbrunn

@rafaelbn
Copy link
Member Author

rafaelbn commented Sep 2, 2016

Solved in #263

@rafaelbn rafaelbn closed this as completed Sep 2, 2016
thomaspaulb pushed a commit to thomaspaulb/web that referenced this issue Dec 5, 2016
yajo pushed a commit to Tecnativa/web that referenced this issue Feb 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants