Help

6

Group by a many2many field

Avatar
nazarii

Hi all. Maybe someone could provide a solution:

Is it possible to use a many2many field in the "Group by" of a search view?

1 Comment
Avatar
Discard
Avatar
Daniel Reis
-

Very good question. In particular, I would really like to see my Partners grouped by Category / v7 Tags ...

2 Answers
5
Avatar
Grover Menacho
Best Answer

I've tried and it's not possible.

After thinking a while I understood why. Let me explain my theory:

A belongs to categ1 categ2

B belongs to categ 2 categ 3

C belongs to categ1 categ 3

Okay if you list this three items:

  • A
  • B
  • C

But if you try to group them by categ. You'll have to repeat A two times B two times and C two times. Group doesn't intend to repeat data it just group the data into sets without common data.

If group worked on many2many it'll do something like this.

  • categ1: A C
  • categ2: B
  • categ2: (empty)

Because it'll show only once the registry and it'll catch them by priority.

Anyways this doesn't work. So if you want to group a many2many you have to do it by python code it's a little bit complicated but I think that there is a way to do it.

Avatar
Discard
-2
Best Answer

Hi Nazarii,

Try Following link,

Many2many domain filtering on v6

Hope it work for you.

3 Comments
Avatar
Discard
Avatar
nazarii
-

Hi Ghanshyam, thanks for reply. But i have no problems with filtering by many2many field, i have a problem with grouping by many2many.

Hi Nazarii, If your problem is solved, then please mark my answer as solved.

Avatar
nazarii
-

Hi again, my problem is not solved as the answer is not related to my question.