Skip to content
Snippets Groups Projects
Commit ef1ff60532b7 authored by Vincent Hatakeyama's avatar Vincent Hatakeyama
Browse files

:sparkles: Add populate options to docker_dev_start

parent efa11618135c
No related branches found
No related tags found
1 merge request!90✨ Add populate options to docker_dev_start
......@@ -11,6 +11,8 @@
Fix chown of extra directories. Add chown option to do_tests.
Add populate options to docker_dev_start.
15.0.0
------
......
......@@ -11,6 +11,22 @@
SECTION = "odoo_scripts"
OTHER_SOURCES_KEY = "other_sources"
ODOO_7 = "odoo7"
"""Value for odoo_type representing Odoo 7.0"""
ODOO_8 = "odoo8"
"""Value for odoo_type representing Odoo 8.0"""
ODOO_9 = "odoo9"
""".. warning: This version is not handled"""
ODOO_10 = "odoo10"
"""Value for odoo_type representing Odoo 10.0"""
ODOO_11 = "odoo11"
"""Value for odoo_type representing Odoo 11.0"""
ODOO_12 = "odoo12"
""".. warning: This version is not handled"""
ODOO_13 = "odoo13"
"""Value for odoo_type representing Odoo 13.0"""
ODOO_14 = "odoo14"
""".. warning: This version is not handled"""
ODOO_15 = "odoo15"
"""Value for odoo_type representing Odoo 15.0"""
......
......@@ -15,7 +15,17 @@
from docker.types import Mount
from psycopg2 import OperationalError, connect
from .config import ODOO_15, Config
from .config import (
ODOO_7,
ODOO_8,
ODOO_9,
ODOO_10,
ODOO_11,
ODOO_12,
ODOO_13,
ODOO_15,
Config,
)
from .docker_build import add_build_options, build_local_image, get_build_options
from .docker_client import DockerClient, modules_mount
from .docker_flake8 import apply_flake8, parser_add_flake8_group
......@@ -127,6 +137,17 @@
" cannot be used at the same time",
action="store_true",
)
populate = group.add_argument_group()
populate.add_argument(
"--populate-model",
help="Populate the indicated model",
default=None,
)
populate.add_argument(
"--populate-size",
help="Populate size",
default=None,
)
parser.add_argument(
"-i",
"--install",
......@@ -301,6 +322,8 @@
odoo_sources = nmspc.odoo_sources
pre_sql_script = nmspc.PRE_SQL
run_chown = nmspc.run_chown
populate_model = nmspc.populate_model
populate_size = nmspc.populate_size
if restore_filename:
if not database:
......@@ -353,7 +376,11 @@
"odoo13",
ODOO_15,
)
arg = ["coverage-start" if coverage else "start"]
arg = [
"populate"
if populate_model or populate_size
else ("coverage-start" if coverage else "start")
]
if db_password:
arg.append("--db_password %s" % db_password)
if nmspc.update:
......@@ -406,6 +433,22 @@
if load_language and installing_or_updating:
arg.append("--load-language")
arg.append(load_language)
if (populate_model or populate_size) and odoo_type in (
ODOO_7,
ODOO_8,
ODOO_9,
ODOO_10,
ODOO_11,
ODOO_12,
ODOO_13,
):
_logger.warning("Populate is not available in your version")
if populate_model:
arg.append("--model")
arg.append(populate_model)
if populate_size:
arg.append("--size")
arg.append(populate_size)
# auto detect local ip
if use_host_network:
......@@ -448,7 +491,7 @@
_logger.info("Local configuration file found: %s", local_conf_path)
odoo_conf_file = (
"/etc/odoo/odoo.conf"
if odoo_type in ("odoo11", "odoo12", "odoo13", ODOO_15)
if odoo_type in (ODOO_11, ODOO_12, ODOO_13, ODOO_15)
else "/opt/odoo/etc/odoo.conf"
)
mounts.append(
......@@ -759,7 +802,7 @@
# developer mode options
if dev:
if odoo_type in ("odoo10", "odoo11", "odoo13", ODOO_15):
if odoo_type in (ODOO_10, ODOO_11, ODOO_13, ODOO_15):
# automatically add reload if not already asks for
if not any(opt in dev_opts for opt in ("all", "reload")):
dev_opts.append("reload")
......@@ -782,6 +825,6 @@
# bind Odoo sources
if odoo_sources:
_logger.info("Binding Odoo sources at %s", odoo_sources)
if odoo_type in ("odoo10", "odoo11", "odoo13", ODOO_15):
if odoo_type in (ODOO_10, ODOO_11, ODOO_13, ODOO_15):
# Image 11 uses python 3.5 if based on xenial, or 3.6 for bionic
# 13 uses bionic
......@@ -786,4 +829,4 @@
# Image 11 uses python 3.5 if based on xenial, or 3.6 for bionic
# 13 uses bionic
if odoo_type == "odoo10":
if odoo_type == ODOO_10:
pythons = ("python2.7",)
......@@ -789,3 +832,3 @@
pythons = ("python2.7",)
elif odoo_type == "odoo11":
elif odoo_type == ODOO_11:
pythons = ("python3.5", "python3.6")
......@@ -791,6 +834,6 @@
pythons = ("python3.5", "python3.6")
elif odoo_type == "odoo13":
elif odoo_type == ODOO_13:
pythons = ("python3.8",)
elif odoo_type == ODOO_15:
pythons = ("python3.9",)
else:
......@@ -793,8 +836,8 @@
pythons = ("python3.8",)
elif odoo_type == ODOO_15:
pythons = ("python3.9",)
else:
pythons = ("python3.6",)
pythons = ("python3.9",)
for python in pythons:
mounts.append(
Mount(
......@@ -817,7 +860,7 @@
"bind",
)
)
elif odoo_type in ("odoo7", "odoo8"):
elif odoo_type in (ODOO_7, ODOO_8):
mounts.append(Mount("/opt/odoo/sources/odoo", odoo_sources, "bind"))
else:
raise Exception("Unexpected odoo_type when binding sources: %s" % odoo_type)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment