-
- Downloads
[FIX] base: add ir_config_parameter with default value
Steps to reproduce:
- install sale_management module;
- go to settings of sale_management and check "Automatic invoice" parameter;
- in debug mode, we can see the template selected (do not change it);
- save the settings;
(This is just one example)
Issue:
The parameter is not added to the "ir_config_parameter" table.
Cause:
The improvement which consists in comparing the settings which one wishes to record with those which already exist in order to set the parameters which are different creates a problem.
Indeed, the current settings are retrieved directly from the model with their default value if there is one.
These are the values that will be used for the comparison.
Because of this, when we want to save a parameter which is set to its default value (on first save), the logic will not notice a difference.
Therefore, the parameter will not be saved in the "ir_config_parameter" table.
Consequence:
In the code, when we wanted to look up the value of a parameter, if it is not saved, we use its default value instead of saving it with its default value.
Example:
```
field_example = fields.Integer(string='Example', default=1000, config_parameter='model.field_example')
value_field_example = params.get_param('model.field_example', default=1000)
```
The default value is repeated.
Solution:
To know whether or not we add a new parameter in the "ir_config_parameter" table, we must look at what already exists in the table and not in the settings defined in the model.
opw-3057306
closes odoo/odoo#106184
X-original-commit: d881dfaaa163b409a94494e35afa2cbda7cf2aa2
Related: odoo/enterprise#34233
Signed-off-by:
Victor Feyens (vfe) <vfe@odoo.com>
Showing
- odoo/addons/base/models/res_config.py 3 additions, 7 deletionsodoo/addons/base/models/res_config.py
- odoo/addons/test_testing_utilities/ir.model.access.csv 1 addition, 0 deletionsodoo/addons/test_testing_utilities/ir.model.access.csv
- odoo/addons/test_testing_utilities/models.py 15 additions, 0 deletionsodoo/addons/test_testing_utilities/models.py
- odoo/addons/test_testing_utilities/tests/__init__.py 1 addition, 0 deletionsodoo/addons/test_testing_utilities/tests/__init__.py
- odoo/addons/test_testing_utilities/tests/test_res_config.py 18 additions, 0 deletionsodoo/addons/test_testing_utilities/tests/test_res_config.py
Please register or sign in to comment