diff --git a/odoo/service/db.py b/odoo/service/db.py index 063d8eaee7d..6bac41282de 100644 --- a/odoo/service/db.py +++ b/odoo/service/db.py @@ -97,7 +97,13 @@ def _create_empty_database(name): raise DatabaseExists("database %r already exists!" % (name,)) else: cr.autocommit(True) # avoid transaction block - cr.execute("""CREATE DATABASE "%s" ENCODING 'unicode' LC_COLLATE 'C' TEMPLATE "%s" """ % (name, chosen_template)) + + # 'C' collate is only safe with template0, but provides more useful indexes + collate = "LC_COLLATE 'C'" if chosen_template == 'template0' else "" + cr.execute( + """CREATE DATABASE "%s" ENCODING 'unicode' %s TEMPLATE "%s" """ % + (name, collate, chosen_template) + ) @check_db_management_enabled def exp_create_database(db_name, demo, lang, user_password='admin', login='admin', country_code=None): diff --git a/odoo/tools/config.py b/odoo/tools/config.py index 7fa33f400fd..1a026486bbb 100644 --- a/odoo/tools/config.py +++ b/odoo/tools/config.py @@ -221,7 +221,7 @@ class configmanager(object): help="specify the database ssl connection mode (see PostgreSQL documentation)") group.add_option("--db_maxconn", dest="db_maxconn", type='int', my_default=64, help="specify the the maximum number of physical connections to PostgreSQL") - group.add_option("--db-template", dest="db_template", my_default="template1", + group.add_option("--db-template", dest="db_template", my_default="template0", help="specify a custom database template to create a new database") parser.add_option_group(group)