Package: odoo-openupgrade-wizard
odoo-openupgrade-wizardOdoo Openupgrade Wizard is a tool that helps developpers to make major
upgrade of Odoo Community Edition. (formely OpenERP).
It works with Openupgrade OCA tools. (https://github.com/oca/openupgrade)this tool is useful for complex migrations:migrate several versionstake advantage of the migration to install / uninstall modulesexecute sql requests or odoo shell scripts between each migrationanalyse workloadIt will create a migration environment (with all the code available)
and provides helpers to run (and replay) migrations until it works.To develop and contribute to the library, refer to theDEVELOP.mdfile.Refer to theROADMAP.mdfile to see the current limitation, bugs, and task to do.See authors in theCONTRIBUTORS.mdfile.Table of ContentsInstallationUsageCommandinitCommandpull-submoduleCommandget-codeCommanddocker-buildCommandrun(BETA)Commandinstall-from-csvCommandupgrade(BETA)Commandgenerate-module-analysis(BETA)Commandestimate-workload(BETA)CommandpsqlCommanddumpdbInstallationPrerequites:The tools run on debian systemYou should have docker installed on your systemSome features require extra packages. To have all the features available run:Installation:The library is available onPyPI.To install it simply run :pipx install odoo-openupgrade-wizard(See alternative installation inDEVELOP.mdfile.)UsageNote:the termodoo-openupgrade-wizardcan be replaced byoowin all the command lines below.Command:initodoo-openupgrade-wizard init\
  --initial-version=10.0\
  --final-version=12.0\
  --project-name=my-customer-10-12\
  --extra-repository=OCA/web,OCA/server-toolsInitialize a folder to make a migration from a 10.0 and a 12.0 database.
This will generate the following structure :filestore/
log/
    2022_03_25__23_12_41__init.log
    ...
postgres_data/
scripts/
    step_1__update__10.0/
        pre-migration.sql
        post-migration.py
    step_2__upgrade__11.0/
        ...
    step_3__upgrade__12.0/
        ...
    step_4__update__12.0/
        ...
src/
    env_10.0/
        extra_debian_requirements.txt
        Dockerfile
        odoo.conf
        extra_python_requirements.txt
        repos.yml
        src/
    env_11.0/
        ...
    env_12.0/
        ...
config.yml
modules.csvconfig.ymlis the main configuration file of your project.modules.csvfile is an optional file. You can fill it with the list
of your modules installed on your production. The first column of this
file should contain the technical name of the module.logfolder will contains all the log of theodoo-openupgrade-wizardand the logs of the odoo instance that will be executed.filestorefolder will contains the filestore of the odoo database(s)postgres_datafolder will be used by postgres docker image to store
database.scriptsfolder contains a folder per migration step. In each step folder:pre-migration.sqlcan contains extra SQL queries you want to execute
before beginning the step.post-migration.pycan contains extra python command to execute
after the execution of the step.
Script will be executed withodoo shellcommand. All the ORM is available
via theenvvariable.srcfolder contains a folder per Odoo version. In each environment folder:repos.ymlenumerates the list of the repositories to use to run the odoo instance.
The syntax should respect thegitaggregatecommand.
(See :https://pypi.org/project/git-aggregator/)
Repo files are pre-generated. You can update them with your custom settings.
(custom branches, extra PRs, git shallow options, etc...)extra_python_requirements.txtenumerates the list of extra python librairies
required to run the odoo instance.
The syntax should respect thepip install -rcommand.
(See :https://pip.pypa.io/en/stable/reference/requirements-file-format/)extra_debian_requirements.txtenumerates the list of extra system librairies
required to run the odoo instance.odoo.conffile. Add here extra configuration required for your custom modules.
the classical keys (db_host,db_port, etc...) are automatically
autogenerated.At this step, you should change the autogenerated files.
You can use default files, if you have a very simple odoo instance without custom code,
extra repositories, or dependencies...Note:In your repos.yml, preserveopenupgradeandserver-toolsrepositories
to have all the features of the librairies available.In your repos.yml file, the odoo project should be in./src/odooand the openupgrade project should be in./src/openupgrade/folder.Command:pull-submodulePrerequites:initif you already have a repos.yml file on github / gitlab, it can be convenient to
synchronize the repository, instead of copy past therepos.ymlmanually.In that case, you can add extra values, in theconfig.ymlfile in the sectionodoo_version_settings:
  12.0:
      repo_url: url_of_the_repo_that_contains_a_repos_yml_file
      repo_branch: 12.0
      repo_file_path: repos.ymlthen run following command :odoo-openupgrade-wizard pull-submoduleCommand:get-codePrerequites:initodoo-openupgrade-wizard get-codeThis command will simply get all the Odoo code required to run all the steps
for your migration with thegitaggregatetools.The code is defined in therepos.ymlof each environment folders. (or in the
directoryrepo_submoduleif you usepull-submodulefeature.)NoteThis step could take a big while !Optional argumentsif you want to update the code of some given versions, you can provide an extra parameter:odoo-openupgrade-wizard get-code --versions 10.0,11.0Command:docker-buildPrerequites:init + get-codeThis will build local docker images that will be used in the following steps.At this end of this step executing the following command should show a docker image per version.$ docker images --filter "reference=odoo-openupgrade-wizard-*"

REPOSITORY                                                 TAG       IMAGE ID       CREATED       SIZE
odoo-openupgrade-wizard-image---my-customer-10-12---12.0   latest    ef664c366208   2 weeks ago   1.39GB
odoo-openupgrade-wizard-image---my-customer-10-12---11.0   latest    24e283fe4ae4   2 weeks ago   1.16GB
odoo-openupgrade-wizard-image---my-customer-10-12---10.0   latest    9d94dce2bd4e   2 weeks ago   924MBOptional argumentsif you want to (re)build an image for some given versions, you can provide
an extra parameter:--versions 10.0,12.0NoteThis step could take a big while also !Command:run(BETA)Prerequites:init + get-code + buildodoo-openupgrade-wizard run\
    --step 1\
    --database DB_NAMERun an Odoo instance with the environment defined by the step argument.The database will be created, if it doesn't exists.ifstop-after-initis disabled, the odoo instance will be available
at your host, at the following url :http://localhost:9069(Port depends on yourhost_odoo_xmlrpc_portsetting of yourconfig.ymlfile)Optional argumentsYou can add--init-modules=purchase,saleto install modules.You can addstop-after-initflag to turn off the process at the end
of the installation.Command:install-from-csvPrerequites:init + get-code + buildodoo-openupgrade-wizard install-from-csv\
    --database DB_NAMEInstall the list of the modules defined in yourmodules.csvfiles on the
given database.The database will be created, if it doesn't exists.To get a correctmodules.csvfile, the following query can be used:psql -c "copy (select name, shortdesc from ir_module_module where state = 'installed' order by 1) to stdout csv" coopiteasyCommand:upgrade(BETA)Prerequites:init + get-code + buildodoo-openupgrade-wizard upgrade\
    --database DB_NAMERealize an upgrade of the database from the initial version to
the final version, following the different steps.For each step, it will :Execute thepre-migration.sqlof the step.Realize an "update all" (in an upgrade or update context)Execute the scripts via XML-RPC (viaodoorpc) defined in
thepost-migration.pyfile.Optional argumentsYou can add--first-step=2to start at the second step.You can add--last-step=3to end at the third step.Command:generate-module-analysis(BETA)Prerequites:init + get-code + buildodoo-openupgrade-wizard generate-module-analysis\
    --database DB_NAME
    --step 2
    --modules MODULE_LISTRealize an analyze between the target version (in parameter via the step argument)
and the previous version. It will generate analysis_file.txt files present
in OpenUpgrade project.
You can also use this fonction to analyze differences for custom / OCA modules
between several versions, in case of refactoring.Command:estimate-workloadPrerequites:init + get-codeodoo-openupgrade-wizard estimate-workloadGenerate an HTML file nameanalysis.htmlwith all the information regarding
the work to do for the migration.checks that the modules are present in each version. (by managing the
renaming or merging of modules)check that the analysis and migration have been done for the official
modules present in odoo/odooCommand:psqlPrerequites:initodoo-openupgrade-wizard psql
    --database DB_NAME
    --command "SQL_REQUEST"Execute an SQL Request on the target database.Optional argumentsIf nodatabaseis provided, defaultpostgresdatabase will be used. exemple:odoo-openupgrade-wizard psql --command "\l";Result:List of databases
    Name    | Owner | Encoding |  Collate   |   Ctype    | Access privileges
------------+-------+----------+------------+------------+-------------------
 postgres   | odoo  | UTF8     | en_US.utf8 | en_US.utf8 |
 template0  | odoo  | UTF8     | en_US.utf8 | en_US.utf8 | =c/odoo          +
            |       |          |            |            | odoo=CTc/odoo
 template1  | odoo  | UTF8     | en_US.utf8 | en_US.utf8 | =c/odoo          +
            |       |          |            |            | odoo=CTc/odoo
 test_psql  | odoo  | UTF8     | en_US.utf8 | en_US.utf8 |if you execute request that return long result, you can choose to selectpageror-no-pageroption to display the result via the click functionecho_via_pager.
(see :https://click.palletsprojects.com/en/8.1.x/utils/#pager-support)Note : Pager is enabled by default.you can pass extra psql arguments inline.odoo-openupgrade-wizard psql
    --database=test_psql
    --command "select id, name from res_partner where name ilike '%admin%';"
    -HResult:<table border="1">
  <tr>
    <th align="center">id</th>
    <th align="center">name</th>
  </tr>
  <tr valign="top">
    <td align="right">3</td>
    <td align="left">Administrator</td>
  </tr>
</table>
<p>(1 row)<br />
</p>See all the options herehttps://www.postgresql.org/docs/current/app-psql.htmlCommand:dumpdbPrerequites:initodoo-openupgrade-wizard dumpdb
    --database DB_NAME
    --database-path DATABASE_PATH
    --filestore-path FILESTORE_PATHDump the database DB_NAME to DATABASE_PATH and export the filestore
related to DB_NAME into FILESTORE_PATH. To choose the format of the
backup files look at the--database-formatand--filestore-format.WARNING: DATABASE_PATH should be a sub directory of the project path
in orter to have the postgresql container able to write the dump file.
For example, the project path is/path/to/myproject(where you run theinitcommand), then DATABASE_PATH can be any of the subdirectory of/path/to/myproject.Optional argumentsTo chose the database format use--database-format. Format can be
one of the following:
-pfor plain sql text
-cfor custom compressed backup ofpg_dump-dfor directory structure
-tfor a tar version of the directory structure
See alsohttps://www.postgresql.org/docs/current/app-pgdump.htmlThe default database format isc.To chose the filestore format use--filestore-format. Format can be
one of the following:
-dcopy of the directory structure
-ttar version of the directory structure (not compressed)
-tgztar version of the directory structure compressed with gzip.
The default filestore format istgz.By default, if database file or filestore file already exists, the
command will fail, preserving the existing dump. If you need to
overwrite the existing files, the--forceoption can be used.