Mutex Toggle Field
by YLHC Technology https://www.ylhctec.com , co. https://www.ylhctec.com , ltd. https://www.ylhctec.com| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Lines of code | 49 |
| Technical Name |
ylhc_mutex_toggle |
| License | OPL-1 |
| Website | https://www.ylhctec.com |
| Versions | 16.0 17.0 18.0 19.0 |
Mutex Toggle Field
Mutually Exclusive Toggle Widget for Odoo List Views
Technical Widget Module
Ylhc Mutex Toggle Field provides a mutually exclusive toggle widget for boolean fields in Odoo list views. When enabled on a record, it automatically disables the toggle on all other records in the list, ensuring only one item can be active at a time. Perfect for selecting a default item, primary record, or exclusive option!
This widget extends Odoo's standard boolean toggle field with mutex (mutually exclusive) functionality. When you toggle a field ON in one record, the widget automatically sets the same field to OFF in all other records. This ensures only one record can have the toggle enabled at any given time - perfect for scenarios like "set as default", "is primary", "featured item", or "active selection".
Visit Our Website for More Information Contact Support: support@ylhctec.com
Usage Guide
Implementing the mutex toggle widget is simple and straightforward. Follow these steps to add mutually exclusive toggle functionality to your boolean fields:
Installation
- Navigate to Apps menu in Odoo
- Search for "Mutex Toggle Field"
- Click Install button
- Wait for installation to complete
Basic Usage
Add the widget to any boolean field in your list view XML:
<field name="is_default" widget="mutex_toggle"/>
Complete Example
Here's a complete example showing how to use the mutex toggle widget in a list view:
<odoo>
<record id="view_partner_bank_tree" model="ir.ui.view">
<field name="name">partner.bank.tree</field>
<field name="model">res.partner.bank</field>
<field name="arch" type="xml">
<tree>
<field name="acc_number"/>
<field name="bank_name"/>
<field name="is_default" widget="mutex_toggle"/>
</tree>
</field>
</record>
</odoo>
Common Use Cases
- Default Selection: Mark one item as the default (e.g., default bank account, default address)
- Primary Record: Designate a primary contact, primary phone number, etc.
- Featured Item: Highlight one featured product, article, or image
- Active Selection: Set one active configuration from multiple options
- Preferred Option: Choose preferred shipping method, payment method, etc.
- The widget only works in list/tree views
- All records must be loaded in the current list view for proper mutex behavior
- The widget patches Odoo's boolean toggle to prevent auto-save
- Works with standard Odoo boolean fields - no model modifications required
Key Features
Ylhc Mutex Toggle Field provides essential functionality for managing mutually exclusive boolean fields in Odoo list views. Simple, efficient, and developer-friendly.
Mutex Functionality
Automatic mutual exclusion - only one record can have the toggle enabled at a time.
Easy Integration
Simply add widget="mutex_toggle" to any boolean field - no model changes required.
List View Optimized
Designed specifically for Odoo list/tree views with seamless user experience.
Controlled Saving
Patches boolean toggle to prevent auto-save, giving you full control over when changes persist.
Clean Code
Well-structured, maintainable JavaScript code following Odoo best practices.
Lightweight
Minimal code footprint with no performance impact on your Odoo instance.
Odoo 18 Ready
Fully compatible with Odoo 18.0 and OWL 2.0 framework.
Developer Friendly
Simple API, clear documentation, and straightforward implementation.
Frequently Asked Questions
Do I need to modify my models to use this widget?
No! The mutex toggle widget works with standard Odoo boolean fields. No model modifications, custom fields, or database changes are required.
Does it work in form views?
The mutex toggle widget is specifically designed for list/tree views. In form views, it will behave as a standard boolean field.
What happens if I toggle a field ON?
When you enable a toggle, the widget automatically sets the same field to OFF in all other visible records in the list. Only one record will have the toggle enabled.
Can I use it on multiple fields?
Yes! You can use the mutex_toggle widget on multiple different boolean fields in the same view. Each field operates independently with its own mutex behavior.
Is it compatible with Odoo Community Edition?
Yes! The widget works perfectly with both Odoo Community and Enterprise editions for version 18.0.
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module