使用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”。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具