Check price_decimal configuration

The price_decimal stored in ir.configuration is checked against the current
configuration value. We do not allow to start serving a database for which the
values are different as it may be due to a misconfiguration which can lead to
data corruption.

issue9324
review317381002
This commit is contained in:
Cédric Krier
2020-05-28 18:22:45 +02:00
parent cf1cdf1c98
commit eed1f5fe58
4 changed files with 15 additions and 2 deletions
+1
View File
@@ -1,3 +1,4 @@
* Add configuration check
* Add support for properties to fields.depends
* Allow combining authentication methods together
* Add context to export CSV route
+4
View File
@@ -29,3 +29,7 @@ class Configuration(ModelSingleton, ModelSQL):
language = config.get('database', 'language')
cls._get_language_cache.set(None, language)
return language
def check(self):
"Check configuration coherence on pool initialisation"
pass
+3
View File
@@ -396,6 +396,9 @@ def load_modules(
load_module_graph(graph, pool, update, lang)
Configuration = pool.get('ir.configuration')
Configuration(1).check()
if update:
cursor.execute(*ir_module.select(ir_module.name,
where=(ir_module.state == 'to remove')))
+7 -2
View File
@@ -158,8 +158,13 @@ class Pool(object):
# Clean the _pool before loading modules
for type in self.classes.keys():
self._pool[self.database_name][type] = {}
restart = not load_modules(self.database_name, self, update=update,
lang=lang, activatedeps=activatedeps)
try:
restart = not load_modules(
self.database_name, self, update=update, lang=lang,
activatedeps=activatedeps)
except Exception:
del self._pool[self.database_name]
raise
if restart:
self.init()