# oca/payroll architecture

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

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

## Overview

##### Project Type & Purpose
- This is an Odoo-based payroll management system composed of several modules (addons) such as hr_payroll_period, payroll, payroll_account, payroll_contract_advantages, payroll_hr_public_holidays, and payroll_rule_time_parameter.
- Its purpose is to extend the Odoo ERP core, providing specialized payroll functionalities—from payroll period management and payslip generation to integration with accounting and handling of contract advantages, public holidays, and time-based payroll rules.

##### Main Components
a. Odoo Core Engine:
- Central Odoo server which handles module loading, ORM, business logic processing, and manages communications between modules.
b. Addon Modules:
- Addon as a separate component. For example:
- hr_payroll_period: handles payroll period creation and sequence data.
- payroll: manages employee payroll records including models, business rules, views, and wizards.
- payroll_account: integrates payroll with accounting functions.
- payroll_contract_advantages: defines and manages contract advantages.
- payroll_hr_public_holidays: integrates public holiday data into payroll calculations.
- payroll_rule_time_parameter: adjusts payroll rules based on time parameter settings.
- Each module’s structure may be further broken down into its internal layers (models, views, data, static resources, and tests) if required for detail.
c. Database (Data Persistence Layer):
- Although not explicitly visible in the file tree, Odoo uses PostgreSQL. Include a component that represents the underlying database which all modules interact with via Odoo’s ORM.
d. External Dependencies & Workflow Automation:
- Optionally, include external services or CI/CD workflows (like those described in the .github/workflows files) to show that automated testing, pre-commit checks, and translation services are part of the broader ecosystem.

##### Relationships & Interactions
- From the Odoo core to each module, showing that the core framework loads and orchestrates these modules at runtime.
- From views (UI) components (in each module’s “views” directories) to the business logic (models) to illustrate how user actions trigger ORM operations.
- Between modules themselves where integration exists (e.g., payroll calling functionalities from hr_payroll_period to manage payroll periods or payroll_account for financial reconciliation).
- From modules to the database, representing persistent data interactions.

##### Architectural Patterns & Principles
- Model-View-Controller (MVC) structure inherent in Odoo:
- Models: Found under “models” directories that implement business logic.
- Views: XML definitions in “views” directories define the UI.
- Workflows (wizards): Manage complex user interactions.
- That each addon adheres to Odoo conventions and uses manifest files (__manifest__.py) to declare dependencies, configurations, and module metadata.
- Separation of concerns: each addon addresses a specific payroll process while integrating smoothly with the core and with each other.

## Diagram (Mermaid)

```mermaid
graph TD
    OdooCore["Odoo Core Engine"]:::core
    Workflows["CI/CD Pipeline & Workflows"]:::cicd

    subgraph "Payroll Modules"
        A1["hr_payroll_period Module"]:::addon
        A2["payroll Module"]:::addon
        A3["payroll_account Module"]:::addon
        A4["payroll_contract_advantages Module"]:::addon
        A5["payroll_hr_public_holidays Module"]:::addon
        A6["payroll_rule_time_parameter Module"]:::addon
    end

    Database["Database (PostgreSQL)"]:::database

    %% Core loads modules
    OdooCore -->|"loads"| A1
    OdooCore -->|"loads"| A2
    OdooCore -->|"loads"| A3
    OdooCore -->|"loads"| A4
    OdooCore -->|"loads"| A5
    OdooCore -->|"loads"| A6

    %% Modules persist data to the database
    A1 -->|"stores_data"| Database
    A2 -->|"stores_data"| Database
    A3 -->|"stores_data"| Database
    A4 -->|"stores_data"| Database
    A5 -->|"stores_data"| Database
    A6 -->|"stores_data"| Database

    %% CI/CD Pipeline triggered from core
    OdooCore -->|"trigger_CI_CD"| Workflows

    %% Module integrations
    A2 -->|"calls_periods"| A1
    A3 -->|"reconciles_payroll"| A2
    A2 -->|"checks_advantages"| A4
    A2 -->|"considers_holidays"| A5
    A2 -->|"applies_time_parameters"| A6

    %% Click Events
    click A1 "https://github.com/oca/payroll/tree/14.0/hr_payroll_period"
    click A2 "https://github.com/oca/payroll/tree/14.0/payroll"
    click A3 "https://github.com/oca/payroll/tree/14.0/payroll_account"
    click A4 "https://github.com/oca/payroll/tree/14.0/payroll_contract_advantages"
    click A5 "https://github.com/oca/payroll/tree/14.0/payroll_hr_public_holidays"
    click A6 "https://github.com/oca/payroll/tree/14.0/payroll_rule_time_parameter"
    click Workflows "https://github.com/oca/payroll/tree/14.0/.github/workflows"

    %% Styles
    classDef core fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef addon fill:#b3e5fc,stroke:#039be5,stroke-width:2px;
    classDef database fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px;
    classDef cicd fill:#ffe0b2,stroke:#ef6c00,stroke-width:2px;
```
