{"library":"openupgradelib","title":"Odoo OpenUpgrade Library","description":"The `openupgradelib` is a Python library providing support functions specifically designed to be called from Odoo migration scripts. It is a fundamental component of the Odoo Community Association (OCA) OpenUpgrade project, which aims to offer an open-source upgrade path for Odoo Community Edition instances between major versions. The library is actively maintained, releasing new versions periodically to ensure compatibility with the latest Odoo versions and to address common data migration challenges.","language":"python","status":"active","last_verified":"Mon May 18","install":{"commands":["pip install openupgradelib","pip install git+https://github.com/OCA/openupgradelib.git@master#egg=openupgradelib"],"cli":null},"imports":["from openupgradelib import openupgrade"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import logging\nfrom openupgradelib import openupgrade\n\n_logger = logging.getLogger(__name__)\n\n@openupgrade.migrate()\ndef migrate(env, version):\n    _logger.info(\"Starting migration script for version %s\", version)\n\n    # Example 1: Execute a raw SQL query with logging\n    openupgrade.logged_query(\n        env.cr,\n        \"UPDATE res_users SET company_id = 1 WHERE company_id IS NULL\",\n        \"Setting default company for users without one\"\n    )\n\n    # Example 2: Add a new column to an existing model\n    # This is typically done in a 'pre-migrate' script to prepare the database schema\n    openupgrade.add_columns(\n        env,\n        [\n            ('res.partner', 'x_migrated_status', 'char', None, 'res_partner', 'varchar(64)', False),\n        ]\n    )\n\n    # Note: After adding columns or fields, Odoo's ORM cache often needs to be cleared or re-initialized\n    # For schema changes, _auto_init() or _fields.clear() might be needed for ORM awareness in later steps.\n    # env['res.partner']._fields.clear()\n    # env.cr.commit() # Commit changes if needed before further ORM operations\n\n    _logger.info(\"Migration script completed.\")","lang":"python","description":"To use `openupgradelib`, create a Python file within your Odoo module's `migrations/<ODOO_VERSION>/` directory (e.g., `my_module/migrations/16.0.1.0/pre-migrate.py`). Decorate your `migrate` function with `@openupgrade.migrate()` to ensure it runs correctly within the OpenUpgrade framework, providing access to the `env` (Odoo environment) and `version` (migration version) objects. This example demonstrates running a logged SQL query and adding a new column, two common migration tasks.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-18","installed_version":"3.13.1","pypi_latest":"3.13.1","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":50,"avg_install_s":2.1,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"git+https://github.com/OCA/openupgradelib.git@master#egg=openupgradelib","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"openupgradelib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"30.4M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"git+https://github.com/OCA/openupgradelib.git@master#egg=openupgradelib","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":1.4,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"openupgradelib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.2,"import_time_s":null,"mem_mb":null,"disk_size":"31M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"git+https://github.com/OCA/openupgradelib.git@master#egg=openupgradelib","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"openupgradelib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"32.3M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"git+https://github.com/OCA/openupgradelib.git@master#egg=openupgradelib","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":1.5,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"openupgradelib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.1,"import_time_s":null,"mem_mb":null,"disk_size":"33M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"git+https://github.com/OCA/openupgradelib.git@master#egg=openupgradelib","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"openupgradelib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"24.3M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"git+https://github.com/OCA/openupgradelib.git@master#egg=openupgradelib","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":1.4,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"openupgradelib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.9,"import_time_s":null,"mem_mb":null,"disk_size":"25M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"git+https://github.com/OCA/openupgradelib.git@master#egg=openupgradelib","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"openupgradelib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"24.0M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"git+https://github.com/OCA/openupgradelib.git@master#egg=openupgradelib","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":1.4,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"openupgradelib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.9,"import_time_s":null,"mem_mb":null,"disk_size":"25M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"git+https://github.com/OCA/openupgradelib.git@master#egg=openupgradelib","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"openupgradelib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"29.9M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"git+https://github.com/OCA/openupgradelib.git@master#egg=openupgradelib","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":1.7,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"openupgradelib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.5,"import_time_s":null,"mem_mb":null,"disk_size":"30M"}]}}