使用OCA/OpenUpgrade升級odoo版本
文檔:
https://oca.github.io/OpenUpgrade/
模塊:
https://github.com/OCA/OpenUpgrade
遷移腳本開發:
https://oca.github.io/OpenUpgrade/080_migration_script_development.html
目的:將odoo舊版本數據升級為新版本可以運行的數據。
# https://oca.github.io/OpenUpgrade/040_run_migration.html
1. Get the code from OpenUpgrade and dependencies
# 下載模塊
git clone https://github.com/OCA/OpenUpgrade.git
# 安裝依賴
pip install openupgradelib
# 從github下載最新版本
# pip install git+https://github.com/OCA/openupgradelib.git@master#egg=openupgradelib
2. Make a copy of the database to migrate
準備好運行新版本odoo的運行環境,可以參考odoo官方部署/開發環境搭建文檔。
備份數據并恢復數據到升級用的數據庫。
可以通過psql工具或原odoo版本的數據庫管理工具進行恢復。
3.Adjust the configuration for Odoo and OpenUpgrade
使用命令參數或在配置中配置好升級腳本路徑
--upgrade-path=<path_to_openupgrade>/openupgrade_scripts/scripts --update all --stop-after-init --load=base,web,openupgrade_framework
如果連續升級多個版本僅需要設置目標版本
export OPENUPGRADE_TARGET_VERSION=13.0
4. Run the upgrade, fix data and repeat…
Run the upgrade and check for errors. You will probably learn a lot about your data and have to do some manual clean up before and after the upgrade. Expect to repeat the process several times as you encounter errors, clean up your data, and try again. If necessary, ask for help or report bugs on GitHub.
Write the missing migration scripts
At this stage, if some of your modules don’t have yet migration scripts, you might need to add them yourself. Read more about the development of migrations scripts in Migration script development
執行升級命令、并處理報錯。開發、調試缺失的升級腳本、第三方的模塊,直至完成升級。
開發腳本的試錯過程
基本上,這是在您嘗試運行升級的步驟中發生的情況 如 運行遷移 中所述:
-
[A] 將舊版本的數據庫副本作為 db-upgrade ,它是 通過舊 Odoo 的數據庫管理器輕松完成 http://localhost:8069/web/database/manager
-
[B] 運行
odoo -d db-upgrade -u all --stop-after-init -
[C] 如果出現錯誤,請修復添加或編輯遷移的錯誤 腳本進行修復,然后使用
-u <fixed_module>而不是-u all。 這種運行方式僅用于測試目的,對您有所幫助 在開發過程中節省大量時間。 每當遇到意外錯誤時,您可能希望從 [A] 重新啟動,因為 此步驟將使數據庫處于不一致狀態。 -
[D] 修復所有問題后,返回
--update all以確保所有 依賴模塊已升級。
使用演示數據生成的生產數據庫將轉換為非演示數據庫。如果你想避免這種情況,你必須通過環境變量 OPENUPGRADE_USE_DEMO,值“yes”。

浙公網安備 33010602011771號