This question has been flagged
1 Reply
5448 Views

Hi,
Apologies for the newbie question but I'm trying to add a 'group-by' option for the products list view.
Specifically - group-by seller (or supplier). Whenever I edit the searchview and add any of the seller related fields, I'm getting an error that the field is related and not database-persisted field. ("Fields in 'groupby' must be regular database-persisted fields (no function or related fields), or function fields with store=True").
This error came when I tried to add my group-by with the following line at the group-by area, right below the 'Type' default group-by (Copied the previous line and changed the "filter string" ad the "group_by" fields values):

<filter string="Seller" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by' : 'seller_ids'}"/>

My questions are:
1. How can I find which are the fields in a view (for example the product list view) can use for a group-by?
2. How can I group-by my products list by a supplier?

Thanks! Gil.

Thanks!

Avatar
Discard
Best Answer

Hi Gil,

You cannot use one2many or many2many field in group by. You can only use these fields for simple search.

Ex:

<field name="seller_ids" string="Sellers"/>

Hope this will help you.

Avatar
Discard
Author

Thanks Sudhir, I was wondering. Is there a way to find which fields ARE available for "Group-by"? And also - does that mean I cannot see products per their suppliers anywhere else in the system? Thanks!

You can search it by Supplier name for that field.

&lt;field name="seller_ids"/&gt;

Author

Thanks for the reply Sudhir, I am aware of the search function and was looking for a "Group by" function. We have about 30 suppliers and I was looking to show a list of all products grouped by each one of our suppliers. If I have to do a "search" I will have to do it 30 times and it will not be one list. Any idea how can I create a list of products (all of them in one list) divided by supplier?