odoo-openupgrade-wizard/odoo_openupgrade_wizard/cli/cli_upgrade.py
Sylvain LE GAL d890a460ea [IMP] Harmonize run and upgrade cli command. Allow to call command with argument --with-demo / --without-demo like in install-from-csv.
For that purpose, create a new decorator.
[REF] Change the default of install-from-csv to harmonize. (allways False)
2024-03-01 15:51:09 +01:00

48 lines
1.3 KiB
Python

import click
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,
)
from odoo_openupgrade_wizard.tools.tools_odoo import (
execute_click_odoo_python_files,
kill_odoo,
run_odoo,
)
from odoo_openupgrade_wizard.tools.tools_postgres import (
execute_sql_files_pre_migration,
)
@click.command()
@first_step_option
@last_step_option
@database_option_required
@demo_option
@click.pass_context
def upgrade(ctx, first_step, last_step, database, with_demo):
migration_steps = get_migration_steps_from_options(
ctx, first_step, last_step
)
for migration_step in migration_steps:
execute_sql_files_pre_migration(ctx, database, migration_step)
try:
run_odoo(
ctx,
migration_step,
database=database,
detached_container=False,
update="all",
stop_after_init=True,
demo=with_demo,
)
except (KeyboardInterrupt, SystemExit):
logger.info("Received Keyboard Interrupt or System Exiting...")
finally:
kill_odoo(ctx, migration_step)
execute_click_odoo_python_files(ctx, database, migration_step)