Merge branch 'ADD-option-execution-demo-etc' into 'main'

[IMP] New options in various cli commands. (with-demo, etc...)

See merge request odoo-openupgrade-wizard/odoo-openupgrade-wizard!57
This commit is contained in:
Rémy Taymans 2024-03-01 19:03:15 +00:00
commit e5a3861cde
4 changed files with 35 additions and 7 deletions

View File

@ -3,6 +3,7 @@ from loguru import logger
from odoo_openupgrade_wizard.cli.cli_options import (
database_option,
demo_option,
get_migration_step_from_options,
)
from odoo_openupgrade_wizard.tools.tools_odoo import (
@ -16,11 +17,7 @@ from odoo_openupgrade_wizard.tools.tools_postgres import ensure_database
@click.command()
@database_option
@click.option(
"--with-demo/--whitout-demo",
default=True,
help="Create database with or without demo data.",
)
@demo_option
@click.pass_context
def install_from_csv(ctx, database, with_demo):
migration_step = get_migration_step_from_options(ctx, 1)

View File

@ -44,6 +44,15 @@ def last_step_option(function):
return function
def demo_option(function):
function = click.option(
"--with-demo/--without-demo",
default=False,
help="Create database with or without demo data.",
)(function)
return function
def database_option(function):
function = click.option(
"-d",

View File

@ -3,6 +3,7 @@ from loguru import logger
from odoo_openupgrade_wizard.cli.cli_options import (
database_option,
demo_option,
get_migration_step_from_options,
step_option,
)
@ -13,6 +14,7 @@ from odoo_openupgrade_wizard.tools.tools_postgres import ensure_database
@click.command()
@step_option
@database_option
@demo_option
@click.option(
"--stop-after-init",
is_flag=True,
@ -27,6 +29,12 @@ from odoo_openupgrade_wizard.tools.tools_postgres import ensure_database
type=str,
help="List of modules to install. Equivalent to -i odoo options.",
)
@click.option(
"-u",
"--update-modules",
type=str,
help="List of modules to update. Equivalent to -u odoo options.",
)
@click.option(
"-e",
"--execution-context",
@ -36,7 +44,16 @@ from odoo_openupgrade_wizard.tools.tools_postgres import ensure_database
" Let empty to use the defaut execution of the migration step.",
)
@click.pass_context
def run(ctx, step, database, stop_after_init, init_modules, execution_context):
def run(
ctx,
step,
database,
with_demo,
stop_after_init,
init_modules,
update_modules,
execution_context,
):
migration_step = get_migration_step_from_options(ctx, step)
ensure_database(ctx, database, state="present")
try:
@ -46,7 +63,9 @@ def run(ctx, step, database, stop_after_init, init_modules, execution_context):
database=database,
detached_container=not stop_after_init,
init=init_modules,
update=update_modules,
stop_after_init=stop_after_init,
demo=with_demo,
execution_context=execution_context,
)
if not stop_after_init:

View File

@ -3,6 +3,7 @@ from loguru import logger
from odoo_openupgrade_wizard.cli.cli_options import (
database_option_required,
demo_option,
first_step_option,
get_migration_steps_from_options,
last_step_option,
@ -21,8 +22,9 @@ from odoo_openupgrade_wizard.tools.tools_postgres import (
@first_step_option
@last_step_option
@database_option_required
@demo_option
@click.pass_context
def upgrade(ctx, first_step, last_step, database):
def upgrade(ctx, first_step, last_step, database, with_demo):
migration_steps = get_migration_steps_from_options(
ctx, first_step, last_step
)
@ -36,6 +38,7 @@ def upgrade(ctx, first_step, last_step, database):
detached_container=False,
update="all",
stop_after_init=True,
demo=with_demo,
)
except (KeyboardInterrupt, SystemExit):
logger.info("Received Keyboard Interrupt or System Exiting...")