This is a useful feature in Odoo that can make the system more user-friendly and help to minimize data entry errors.
There are several ways to set this up.
The simplest way is to enable developer mode and then select “Set Defaults” from the Debug menu.
This will display a list of fields (with their values) and you can select one. In this case we will set Product Type to “Storable Product”
You can also add a condition (e.g. this applies for a specific Product Category).
You can also decide whether this applies to the current user or all users:
Click on “Save Default” and it’s done.
We can review this in Settings / Technical / User-defined Defaults:
Click on it to display details
Here you can make changes.
For example, remove the company so this applies to all companies.
From this menu we can also add new defaults (you can search for field names).
Set fields to blank
It’s not possible to set fields to blank using the “debug menu” but this can be done from the Settings menu.
For example, in Odoo 12 (and earlier) we might want to set all new products to be shared across companies:
This is the result:
Sometimes we want to set different values based on conditions.
For example, we can set the product type to “Service” if the category is “Consultation fee” (but not for other product categories).
We’ll do it through the debug menu:
When we review this we will see that “Condition” is not displayed, but it can easily be added using Studio.
- Field Name = categ_id
- Record ID = 5 (on the Product Category model product.category).
You could setup other defaults by copying this and changing the Product Category and the desired Product Type.
Yes, there is another way. You can use Odoo Studio:
Note that because Product Type is a selection field you can choose a default from the available values.
- If this was a text field you could enter any text.
- If it was a numeric field you could enter any number
- If it’s a relational field you cannot use Odoo Studio to set a default (but it should be possible in debug mode).