Inconsistent access to res.config.settings in multiple modules made only for flectra
In the modules
helpdesk_project_ext you use the following code to get the configuration:
config_id = self.env['res.config.settings'].search(, order='id desc', limit=1)
But this code only works when you have opened the settings some minutes before. After a while, when the vacuum process has cleaned all transient models, there is not record to find. This will result in unexpected behavior like missing warning when discount is bigger than allowed.
Steps to reproduce
- Configure sale_discount with a max fixed discount allowed
- Create a sale order with discount that exceeds the configured limit --> You will get the warning
- run the autovacuum job or restart flectra
- Create another sale order with discount that exceeds the configured limit --> No warning showing!!!
What is the current bug behavior?
The configuration is lost when not opening the settings first.
What is the expected correct behavior?
Load the configuration correct to always have the same behavior with e.g.
config_id = self.env['res.config.settings'].create()
config_data = self.env['res.config.settings'].get_values()
or maybe best solution
Save the settings on res.company and make these settings company depending
As I am not shure which fix you would prefer I haven't made a MR. But if you let me know the desired solution, I will gladly provide it as MR.