# oca/openupgrade architecture

> Architecture diagram of the GitHub repository oca/openupgrade, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/oca/openupgrade
- Repository: https://github.com/oca/openupgrade

## Overview

##### Project Overview and Purpose
- OpenUpgrade is an open source tool designed to upgrade Odoo instances from one major version to another. It consists of two primary components:
– The openupgrade_framework: a module that integrates with Odoo’s server (via server‐wide modules) and provides functionality to help patch or adapt Odoo’s internal components during an upgrade.
– The openupgrade_scripts: a collection of migration analyses and scripts that perform specific upgrade tasks for individual Odoo modules.
- The README and file tree clearly indicate that the project is comprised of “addons” (Odoo modules) which, when combined, form a migration framework.

##### Main Components
a. Odoo Instance: Represent an Odoo server instance as the target system environment that needs upgrading.
b. OpenUpgrade Framework Component:
- The “odoo_patch” submodule and its modifications to Odoo’s core addons and API.
- The fact that it integrates at the server level (often via the “server_wide_modules” option).
c. OpenUpgrade Scripts Component:
- Pre-migration actions (e.g., pre-migration.py)
- Post-migration actions (e.g., post-migration.py)
- Analysis reports (“upgrade_analysis.txt” and “upgrade_analysis_work.txt”)
d. CI/CD and Quality Tools:
– Although secondary to the runtime architecture, include parts that indicate static analysis tools (e.g., pre-commit configurations, GitHub workflows, lint configurations) which feed into continuous integration.
e. Documentation and Metadata:
– A component for documentation (both docsource and build_openupgrade_docs) to indicate that there is external documentation that explains migration policies and processes.
f. Configuration Files and Package Managers:
– Represent configuration files (e.g., setup, pyproject.toml, requirements.txt) that link to build and dependency-management aspects of the project.

##### Relationships and Interactions
– “Pre-migration analysis” → “Script Execution” → “Odoo Instance Upgrade Process”
– “Post-migration routines” → “Verification and Logging” (which can be tied to CI/CD output).

##### Architectural Patterns and Design Principles
- Dependency inversion is evident: the scripts depend on a stable core (framework) that abstracts Odoo’s internal changes.

##### Technologies and Tools
– Python, Odoo, and perhaps references to configuration management (e.g., pre-commit, GitHub Actions).
- Mention that the scripts often handle XML, Python migrations, and analysis text files. This indicates that file-driven workflow elements are part of the migration automation.

##### Final Remarks
- The goal is to capture the “flow” of an upgrade: starting from reading the module-specific migration analysis, processing it through the migration scripts, leveraging the framework to patch Odoo internals, and resulting in an upgraded Odoo instance.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Odoo Environment"
        OdooInstance["Odoo Instance"]:::external
    end

    subgraph "OpenUpgrade Framework"
        Framework["openupgrade_framework (Core Patching Module)"]:::framework
        OdooPatch["odoo_patch (Internal Patches)"]:::framework_patch
    end

    subgraph "Migration Scripts"
        Scripts["openupgrade_scripts (Migration Collection)"]:::scripts
        SubScripts["Script Directories (e.g., account, hr, sale)"]:::scripts
    end

    subgraph "CI/CD & Quality Tools"
        CICD["CI/CD Pipeline & Quality Tools"]:::cicd
    end

    subgraph "Documentation & Metadata"
        DocBuild["build_openupgrade_docs (Doc Build)"]:::docs
        DocSource["docsource (Doc Source)"]:::docs
        README["README & Metadata"]:::docs
    end

    subgraph "Configuration & Package Management"
        Pyproject["pyproject.toml (Build System)"]:::config
        Requirements["requirements.txt (Dependencies)"]:::config
        Setup["setup (Setup Scripts)"]:::config
    end

    Scripts -->|"uses"| Framework
    SubScripts -->|"triggers"| Framework
    Framework -->|"patches"| OdooInstance

    CICD -->|"tests"| Framework
    CICD -->|"tests"| Scripts

    Pyproject -->|"defines"| Framework
    Pyproject -->|"defines"| Scripts
    Requirements -->|"defines"| Framework
    Requirements -->|"defines"| Scripts
    Setup -->|"integrates"| Framework
    Setup -->|"integrates"| Scripts

    DocBuild -->|"documents"| Framework
    DocBuild -->|"documents"| Scripts
    README -->|"provides"| Framework
    README -->|"provides"| Scripts

    click OdooInstance "https://github.com/oca/openupgrade/tree/17.0/openupgrade_framework/odoo_patch/odoo"
    click Framework "https://github.com/oca/openupgrade/tree/17.0/openupgrade_framework"
    click OdooPatch "https://github.com/oca/openupgrade/tree/17.0/openupgrade_framework/odoo_patch"
    click Scripts "https://github.com/oca/openupgrade/tree/17.0/openupgrade_scripts"
    click SubScripts "https://github.com/oca/openupgrade/tree/17.0/openupgrade_scripts/scripts"
    click CICD "https://github.com/oca/openupgrade/tree/17.0/.github/workflows"
    click DocBuild "https://github.com/oca/openupgrade/tree/17.0/build_openupgrade_docs"
    click DocSource "https://github.com/oca/openupgrade/tree/17.0/docsource"
    click README "https://github.com/oca/openupgrade/blob/17.0/README.md"
    click Pyproject "https://github.com/oca/openupgrade/blob/17.0/openupgrade_framework/pyproject.toml"
    click Requirements "https://github.com/oca/openupgrade/blob/17.0/requirements.txt"
    click Setup "https://github.com/oca/openupgrade/tree/17.0/setup"

    classDef external fill:#ffebcd,stroke:#8b4513,stroke-width:2px;
    classDef framework fill:#b3e5fc,stroke:#0277bd,stroke-width:2px;
    classDef framework_patch fill:#81d4fa,stroke:#0288d1,stroke-width:2px;
    classDef scripts fill:#ffccbc,stroke:#e64a19,stroke-width:2px;
    classDef cicd fill:#c5e1a5,stroke:#7cb342,stroke-width:2px;
    classDef docs fill:#d1c4e9,stroke:#673ab7,stroke-width:2px;
    classDef config fill:#fff9c4,stroke:#fdd835,stroke-width:2px;
```
