summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Dony <odo@odoo.com>2018-09-24 12:30:49 +0200
committerOlivier Dony <odo@odoo.com>2018-09-24 12:30:49 +0200
commitcb2862ad2a60ff4ce66c14e7af2548fdf6fc5961 (patch)
tree82c25b35be17d227689c7195e223fa5671cabf03
parent925fdbc683c546e096d1ae99aa22606480f78a0e (diff)
[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 <db>`, causing the db boostrap to happen if the database did not exist yet.
-rw-r--r--odoo/cli/server.py1
-rw-r--r--odoo/cli/start.py2
-rw-r--r--odoo/modules/loading.py3
3 files changed, 6 insertions, 0 deletions
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