changeset 7183035066d4 in trytond:default details: https://hg.tryton.org/trytond?cmd=changeset;node=7183035066d4 description: 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 diffstat: CHANGELOG | 1 + trytond/ir/configuration.py | 4 ++++ trytond/modules/__init__.py | 3 +++ trytond/pool.py | 9 +++++++-- 4 files changed, 15 insertions(+), 2 deletions(-) diffs (51 lines): diff -r cb334e6fd66b -r 7183035066d4 CHANGELOG --- a/CHANGELOG Thu May 28 18:17:40 2020 +0200 +++ b/CHANGELOG Thu May 28 18:22:45 2020 +0200 @@ -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 diff -r cb334e6fd66b -r 7183035066d4 trytond/ir/configuration.py --- a/trytond/ir/configuration.py Thu May 28 18:17:40 2020 +0200 +++ b/trytond/ir/configuration.py Thu May 28 18:22:45 2020 +0200 @@ -29,3 +29,7 @@ language = config.get('database', 'language') cls._get_language_cache.set(None, language) return language + + def check(self): + "Check configuration coherence on pool initialisation" + pass diff -r cb334e6fd66b -r 7183035066d4 trytond/modules/__init__.py --- a/trytond/modules/__init__.py Thu May 28 18:17:40 2020 +0200 +++ b/trytond/modules/__init__.py Thu May 28 18:22:45 2020 +0200 @@ -396,6 +396,9 @@ 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'))) diff -r cb334e6fd66b -r 7183035066d4 trytond/pool.py --- a/trytond/pool.py Thu May 28 18:17:40 2020 +0200 +++ b/trytond/pool.py Thu May 28 18:22:45 2020 +0200 @@ -158,8 +158,13 @@ # 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()