| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Lines of code | 796 |
| Technical Name |
x2many_search_view |
| License | LGPL-3 |
| Versions | 17.0 18.0 19.0 |
X2Many Search View
This module adds full search view functionality (filters, group by) to x2many fields displayed as tree views inside form views.
Overview
This module extends the functionality of x2many (one2many/many2many) fields in form views by adding a complete SearchBar component above the tree view. This allows users to filter, group, and search records within x2many fields just like they would in regular list views.
Features
SearchBar Component
- Full SearchBar component integration above x2many tree views
- Automatically loads the search view for the related model
- Only appears for list view mode (not kanban views)
Filtering
- Predefined Filters: All filters defined in the search view are available
- Custom Filters: Create custom filters directly from the x2many field
- Client-side Filtering: Filters are applied instantly without page reload
- Domain Support: Full domain expression support for complex filtering
Group By
- Single Group By: Group records by any field
- Multiple Group By: Support for nested grouping (e.g., group by Year → Month → Day)
- Date Intervals: Full support for date grouping with intervals (day, week, month, quarter, year)
- Null Value Handling: Records with null values are grouped under "Undefined"
- Group Counts: Accurate record counts for parent and child groups
- Server-side Grouping: Uses Odoo's
read_groupfor efficient grouping
Search Field
- Quick search functionality
- Search across multiple fields as defined in the search view
- Real-time filtering as you type
Favorites
- Save frequently used filter combinations
- Access saved favorites from the x2many field
Screenshots
SearchBar in X2Many Field
This screenshot demonstrates how the SearchBar component appears above the x2many tree view, providing access to all search functionality directly within the form view.
Filtering Functionality
This screenshot shows how filters can be applied to x2many records, allowing users to quickly narrow down the displayed records without leaving the form view.
Search By Typing
This screenshot shows the filter when the user starts to input text in the searchbar
Group By Functionality
This screenshot demonstrates the group by functionality, showing how records can be organized into groups with expandable/collapsible sections.
Multiple Group By (Nested Groups)
This screenshot illustrates the advanced grouping capability, showing how multiple group by levels create a hierarchical structure with accurate record counts at each level.
Date Grouping with Intervals
This screenshot demonstrates date grouping functionality, showing how date fields can be grouped using different time intervals (day, week, month, quarter, year).
Custom Filter Creation
This screenshot shows how users can create custom filters directly from the x2many field, providing flexibility to filter by any field in the related model.
Usage
Basic Setup
The module works automatically once installed. No additional configuration is required.
- Define a search view for your x2many field's related model (if not already defined)
- Open any form view that contains an x2many field with a tree view
- The search view will automatically appear above the x2many tree view
- Use filters and group by just like in regular list views
Example: Sale Order Lines
If you have a form view with an x2many field:
<field name="order_line_ids">
<tree>
<field name="product_id"/>
<field name="quantity"/>
<field name="price_unit"/>
</tree>
</field>
And you have a search view for sale.order.line:
<record id="sale_order_line_view_search" model="ir.ui.view">
<field name="name">sale.order.line.search</field>
<field name="model">sale.order.line</field>
<field name="arch" type="xml">
<search>
<field name="product_id"/>
<filter string="Uninvoiced" name="uninvoiced" domain="[('invoice_status', '=', 'to invoice')]"/>
<group expand="0" string="Group By">
<filter string="Product" name="group_by_product" context="{'group_by': 'product_id'}"/>
<filter string="Date" name="group_by_date" context="{'group_by': 'date_order:day'}"/>
</group>
</search>
</field>
</record>
The search view will automatically appear above the order lines in the sale order form view, allowing you to:
- Filter order lines (e.g., show only uninvoiced lines)
- Group by product, date, etc.
- Search for specific products
Compatibility
- Compatible with Odoo 18.0+ and 19.0+
- Works with both one2many and many2many fields
- Only activates for list view mode (not kanban views)
- Fully compatible with existing search views
Known Limitations
- Only works with list view mode (kanban views are not supported)
- Requires a search view to be defined for the related model (falls back to empty search view if not found)
- Grouping requires server-side reload, which may be slower for large datasets
Troubleshooting
SearchBar Not Appearing
- Ensure the x2many field is displayed in list view mode (not kanban)
- Check that the related model has a search view defined (or the module will create an empty one)
- Verify the module is properly installed and assets are loaded
Filters Not Working
- Check that the filter domain is correct in the search view definition
- Verify field names in filters match the actual field names in the model
- Check browser console for any JavaScript errors
Group By Not Working
- Ensure the field you're grouping by exists in the related model
- For date fields, verify the date interval format (e.g.,
date:day,date:month) - Check that field definitions are properly loaded (check browser console)
Date Grouping Showing "Undefined"
- This should be fixed in the latest version
- If still occurring, check that the date field is not null for all records
- Verify the date field format in the model
Please log in to comment on this module