Skip to content

Commit

Permalink
[IMP] core: require install mode for db bootstrap
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
odony committed Sep 24, 2018
1 parent 925fdbc commit cb2862a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions odoo/cli/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions odoo/cli/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import sys

import odoo
from . import Command
from .server import main
from odoo.modules.module import get_module_root, MANIFEST_NAMES
Expand Down Expand Up @@ -60,6 +61,7 @@ def run(self, cmdargs):
# 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:
Expand Down
3 changes: 3 additions & 0 deletions odoo/modules/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cb2862a

Please sign in to comment.