From cb2862ad2a60ff4ce66c14e7af2548fdf6fc5961 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 24 Sep 2018 12:30:49 +0200 Subject: [PATCH] [IMP] core: require install mode for db bootstrap The registry loading system should not alter databases unless it is asked to do so, by a module installation or update instruction. This property should hold true as well for database bootstrap, and this is what this commit changes.. In order to avoid any behavior change for command-line users, an implicit `-i base` is assumed when starting the server from the command-line with `-d `, causing the db boostrap to happen if the database did not exist yet. --- odoo/cli/server.py | 1 + odoo/cli/start.py | 2 ++ odoo/modules/loading.py | 3 +++ 3 files changed, 6 insertions(+) diff --git a/odoo/cli/server.py b/odoo/cli/server.py index 8809cda542a..93f40126839 100644 --- a/odoo/cli/server.py +++ b/odoo/cli/server.py @@ -138,6 +138,7 @@ def main(args): for db_name in preload: try: odoo.service.db._create_empty_database(db_name) + config['init']['base'] = True except ProgrammingError as err: if err.pgcode == errorcodes.INSUFFICIENT_PRIVILEGE: # We use an INFO loglevel on purpose in order to avoid diff --git a/odoo/cli/start.py b/odoo/cli/start.py index c42494b60b1..d695f6e4860 100644 --- a/odoo/cli/start.py +++ b/odoo/cli/start.py @@ -7,6 +7,7 @@ import itertools import os import sys +import odoo from . import Command from .server import main from odoo.modules.module import get_module_root, MANIFEST_NAMES @@ -60,6 +61,7 @@ class Start(Command): # TODO: forbid some database names ? eg template1, ... try: _create_empty_database(args.db_name) + odoo.tools.config['init']['base'] = True except DatabaseExists as e: pass except Exception as e: diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py index 7d79626d0fc..6f2ee27c8e6 100644 --- a/odoo/modules/loading.py +++ b/odoo/modules/loading.py @@ -333,6 +333,9 @@ def load_modules(db, force_demo=False, status=None, update_module=False): with db.cursor() as cr: if not odoo.modules.db.is_initialized(cr): + if not update_module: + _logger.error("Database %s not initialized, you can force it with `-i base`", cr.dbname) + return _logger.info("init db") odoo.modules.db.initialize(cr) update_module = True # process auto-installed modules