Jaydeep Barot
Jaydeep Barot

Reputation: 11

groupby on many2many relation field in search view?

 `<group expand="0" string="Group By...">
       <filter string="Creator" help="By Responsible" context="{'group_by': 'user_id'}"/>
       <filter string="Status" help="By State" context="{'group_by': 'state'}"/>
       <filter string="categorys" help="By Category" context="{'group_by':'category_ids'}"/>
  </group>`
  1. Third filter is not groupby. because category_ids field is many2many relationship.
  2. Give me ans it's possible or not.

Upvotes: 1

Views: 1939

Answers (1)

user1576199
user1576199

Reputation: 3207

Its not possible.

Lets take an example

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.

Here is link: http://help.openerp.com/question/22335/group-by-a-many2many-field

Upvotes: 1

Related Questions