# oca/purchase-workflow architecture

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

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

## Overview

This repository is an Odoo-based suite – specifically an OCA (Odoo Community Association) “purchase‐workflow” project that groups together a large number of Odoo addons to enhance and extend the purchase order and procurement processes. In other words, it’s not a monolithic application but a collection of interrelated modules (each with its own models, views, and business logic) that run inside the Odoo framework. Many directories in the file tree correspond to individual addons, and a “setup” area organizes how these modules are installed into the Odoo environment.

##### Overall Architecture Context
- Supporting components – e.g., the underlying PostgreSQL database, a web server (if separate), and file storage.
- That all modules in this repository “plug into” the common Odoo framework which handles ORM, workflows, and web presentation.

##### Main Components (modules/addons)
- For example, modules that affect purchase order processing (such as “purchase_order_approval_block”, “purchase_order_revision”, “purchase_order_supplierinfo_update”, etc.).
- Modules that add additional information or views (e.g., “partner_supplierinfo_smartbutton”, “product_main_seller”).
- Modules that adjust workflow aspects, validations, discounts, pricing recalculation, and so on.

##### Relationships and Interactions
- That all these modules extend or override standard Odoo models – for example, “purchase.order”, “purchase.order.line”, “stock.move”, “res.partner”, etc.
- Interactions between modules if one depends on data provided by another (e.g., a module that provides supplier info and another that uses that information for discount calculation).

##### Architectural Patterns and Design Principles
- The system follows a “plugin” architecture where each addon encapsulates its own models (in the models/ directories), views (in the views/ directories), and business logic (wizards, controllers, reports).
- That configuration and deployment is managed externally – see the “setup” directory that contains Odoo addons packing tools. You might represent a “Deployment” or “Configuration” block which ties into the modules.

##### Technologies and Integration
- Mention that the project builds on Python (for models, business objects, and controllers) and XML (for views and workflows), with additional configurations in YAML and other scripts (pre-commit, CI workflows).
- Additionally, show that internationalization (i18n) is integral since almost every module contains i18n files to support multiple languages.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        DB["PostgreSQL Database"]:::infra
        OdooServer["Odoo Application Server"]:::server
        WebServer["Web Server"]:::server
        FileStorage["File Storage"]:::infra
    end

    %% Odoo Core Layer
    subgraph "Odoo Core Layer"
        Core["Odoo Core Framework"]:::core
        PurchaseModel["Purchase Order Model"]:::core
        PartnerModel["Res Partner Model"]:::core
        Setup["Configuration Setup"]:::setup
    end

    %% Addon Layer: Purchase Workflow Enhancements
    subgraph "Addon Layer: Purchase Workflow Enhancements"
        PORevision["Purchase Order Revision"]:::addon
        POApproval["Purchase Order Approval Block"]:::addon
        POSupplierUpdate["Purchase Order Supplierinfo Update"]:::addon
        PartnerSmart["Partner Supplierinfo Smartbutton"]:::addon
        ProductSeller["Product Main Seller"]:::addon
    end

    %% Infrastructure connections
    WebServer --> OdooServer
    FileStorage --> OdooServer
    DB --> OdooServer

    %% Core connections
    OdooServer --> Core
    Setup --> Core

    %% Addon to Core connections (Plugins extending core functionality)
    PORevision -->|"extends"| PurchaseModel
    POApproval -->|"extends"| PurchaseModel
    POSupplierUpdate -->|"extends"| PurchaseModel
    PartnerSmart -->|"enhances"| PartnerModel
    ProductSeller -->|"updates"| PurchaseModel

    %% Additional plugin connection arrows to indicate integration with the core framework
    PORevision --- Core
    POApproval --- Core
    POSupplierUpdate --- Core
    PartnerSmart --- Core
    ProductSeller --- Core

    %% Click Events for component mapping (paths are click targets)
    click Setup "https://github.com/oca/purchase-workflow/tree/16.0/setup"
    click PartnerSmart "https://github.com/oca/purchase-workflow/tree/16.0/partner_supplierinfo_smartbutton"
    click PORevision "https://github.com/oca/purchase-workflow/tree/16.0/purchase_order_revision"
    click POApproval "https://github.com/oca/purchase-workflow/tree/16.0/purchase_order_approval_block"
    click POSupplierUpdate "https://github.com/oca/purchase-workflow/tree/16.0/purchase_order_supplierinfo_update"
    click ProductSeller "https://github.com/oca/purchase-workflow/tree/16.0/product_main_seller"

    %% Styling classes for colour
    classDef infra fill:#f9f,stroke:#333,stroke-width:2px;
    classDef server fill:#bbf,stroke:#333,stroke-width:2px;
    classDef core fill:#cfc,stroke:#333,stroke-width:2px;
    classDef addon fill:#fc9,stroke:#333,stroke-width:2px;
    classDef setup fill:#cff,stroke:#333,stroke-width:2px;
```
