odoo-openupgrade-wizard/odoo_openupgrade_wizard/cli/cli_upgrade.py
Sylvain LE GAL 4fc7056932 [IMP] oow upgrade. Add skip_update as an option in config.yml. (migration_step option). If enabled, in this step, the update all will be skipped, and only pre-migration (SQL) and post-migration (python script) will be executed.
This is interesting:
- for the first step, if your production is up-to-date, to save time.
- for the last step, in recent version (since V14), where openupgrade doesn't contain odoo code. In that case, you should be sure that all your migration is OK, because in openupgrade context, some errors are just ignored.
Use this option with caution.
2025-02-03 11:26:37 +01:00

59 lines
1.8 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)
if not migration_step.get("skip_update", False):
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, database, migration_step)
elif migration_step.get("execution_context") == "openupgrade":
logger.warning(
"Incorrect setting skip_update = True"
" and execution_context = 'openupgrade'..."
)
else:
logger.info(
f"Skip update all for version {migration_step.get('version')}."
)
execute_click_odoo_python_files(ctx, database, migration_step)