Introduction
Looking to enhance your Business Management ERP experience with a custom and intuitive record selection popup? In this guide, you’ll learn how to build a Many2many selection field within a custom dialog popup using the OWL (Odoo Web Library) framework in Odoo 17.
Whether you need a product picker for sales orders or a multi-record selector for custom modules, this tutorial gives you a clean, scalable solution with step-by-step instructions. Let’s dive in and make your Odoo UI smarter and more user-friendly!
Prerequisites
Make sure you have the following before proceeding:
-
Odoo 17 Community or Enterprise installed and running.
-
Basic understanding of OWL and Odoo module development.
-
Your custom module structure is set up with JavaScript, XML, and client actions.
Step-by-Step Implementation
1. JavaScript Component (multiselection.js)
Defines the OWL component and handles record selection logic.
2. OWL Template (multiselection.xml)
Defines the layout and structure of the dialog box.
3. Client Action (client_action.xml)
Triggers the popup from a view like sale.order.
How to Integrate
1. Module Structure
Ensure your module follows this layout:
2. Update __manifest__.py
3. Install or Upgrade
Install or upgrade your module in Odoo to register and activate the new client action.
Testing Your Dialog
-
Go to Sales > Orders.
-
Use the client action (e.g., via a button or menu) to trigger the “Choose Product” popup.
-
The dialog will show a list of inactive products (per the domain).
-
Select multiple records; their display names and IDs will be stored in the component state.
Customizations & Use Cases
-
Change the Model: Update
product.templateto another model (e.g.,res.partner). -
Modify the Domain: Customize the domain logic for your use case, e.g.,
[['customer_rank', '>', 0]]. -
Add Backend Logic: Save selected
resIdsto a model or trigger additional logic. -
Styling: Enhance the visual design via custom CSS or additional OWL components.
Conclusion
By integrating a Many2many selection field within a custom dialog popup using OWL in Odoo 17, you’re empowering your ERP with highly interactive UI elements.
The use of MultiRecordSelector makes it efficient and user-friendly, and with a few tweaks, you can adapt this solution to various business needs across your Business Management ERP modules.