This blog post is the third in a series that showcase great OCA modules. The goal is to make the Odoo world aware of the awesome features built by the OCA contributors over the last 10 years and to publicly thank them for their amazing work and dedication.
The first modules were selected by the OCA functional working group based on their expertise in Odoo implementation. We also thank them for their contributions!
Would you like to share your “best” OCA modules and see them featured in the next blog post? Contact us!
When using Odoo, have you ever wanted to easily restrain the creation of new values in a drop-down list? Or wanted all drop-down lists to show only a certain number of values?
In the standard version, the drop-down list shows up to 8 proposals. If there are fewer, it will show the number of proposals, and if there are more, it will propose “Search more”. With the module presented here, you can decide to show more or less than 8 values. This can be useful if you want to show all 10 proposed values without having to use the “Search more” button. Or if for greater clarity you only want to show 2 values before using the “Search more” button.
The web_m2x_options OCA module lets you modify the “many2one” and “many2manytags” form widgets in just a few clicks to add new display control options, such as changing the default number of proposals appearing in a drop-down list. It can also provide the ability to delete the “create” or “create and modify” options to a drop-down list. This can indeed be a nightmare where dozens of wrong data are entered just by inadvertently click on the Enter key while searching for an existing data.
This module was initially created in Odoo version 7.0 (in 2013), by Nicolas Jeudy and Valentin Lab. Many contributors then worked on migrating this module from version to version, until version 17 today, and very soon version 18.
How to use this module?
1. Change the number of values shown on M2O fields
Let's imagine that we would like all lists in Odoo to display by default only 5 values. More values can be shown by selecting the “Search more” button.
Why would we want that? There could be different reasons for this, such as making it easier to read and use from a small smartphone screen. It could also be to offer the 5 most frequently used fields and not show the others by default, as they are unlikely to be used and therefore don't need to be displayed automatically.
On the other hand, we would like to modify certain lists, for example the list of ‘industries’ proposed on our contacts.
Let’s see how to do that with the ‘web_m2x_options’ module from OCA:
Once you have installed the “web_m2x_options” application on your database, you need to activate the developer tools (debug mode) and access the ‘Configurations’ → ‘Technical’ → ‘Technical parameters’ → ‘System parameters’ menu.
In this menu, you can add a new system parameter: ‘web_m2x_options.limit and complete the ‘value’ field. If you select ‘5’ as value, only 5 propositions will be shown by default in the different drop-down lists of your database.
We could also decide to leave the possibility of creating new values on all lists by adding a line to these configurations, as in the example below.
2. Disable the creation possibility on specific fields
But the web_m2x_options module also enables you to easily decide if the ‘create’ and the ‘create and edit’ option should be visible or not on each separate field. Let's say that you do not want to allow this option for all lists, but only for one: the list of industries present on contact sheets.
To do so, you need to delete the above mentioned system parameter and go to the Contacts application.
To change this value, you simply need to access the ‘debug mode’ and select the “Edit View: Form” feature in the drop-down list proposed when you click on the beetle (developer tools).
When you open this configuration, you need to search in the “architecture” tab for the field for which you wish to modify the drop-down list. In our example, it is the “industry” field.
In the example below, we see that Odoo is configured to block the creation of new values (“no_create” is true). If you wish to allow the creation of values, you simply need to replace this value by "{'web_m2x_options.create_edit': True}".
And here is the result.
Of course, this is just one example, and it is possible to do a multitude of things with this module! All these options can be applied to all many2one and many2many fields, or just to a particular field.
Thanks again to the authors of the latest versions:
initOS GmbH
ACSONE SA/NV
0k.io
Tecnativa
Sygel
And all contributors :
David Coninckx, Emanuel Cino, Holger Brunn, Nicolas JEUDY, Yannick Vaucher , Zakaria Makrelouf, Tecnativa: Jairo Llopis and David Vidal, Ernesto Tejeda, Carlos Roca, Bhavesh Odedra, Dhara Solanki, Trobz: Hoang Diep, Manuel Regidor, Valentín Vinagre and Harald Panten.
This blog post was written by Marie Verzin, part of the Acsone Team and reviewed by the OCA consultants working group and Rebecca Gellatly. Thanks again!
Discover the other articles of this series
How to make an advanced search in Odoo? Do you know web_advanced_search?
How to edit several fields at once in Odoo? Do you know the Server Action Mass Edit Module?
Become an OCA Member
Do you think that the OCA helps you in your Odoo journey? Show us your support, become a Member now.