Metadata-Version: 2.4
Name: odoo-hotupgrade
Version: 0.1.0
Summary: Hot-upgrade Odoo modules on save — no manual upgrades, no container restarts
Project-URL: Homepage, https://github.com/anteneh1621/odoo-hotupgrade
Project-URL: Bug Tracker, https://github.com/anteneh1621/odoo-hotupgrade/issues
Author-email: Anteneh <anteneh@aau2nd.edu.et>
License-Expression: MIT
License-File: LICENSE
Keywords: development,docker,hotupgrade,odoo,upgrade
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Build Tools
Requires-Python: >=3.10
Requires-Dist: click>=8.4.1
Requires-Dist: pydantic>=2.13.4
Requires-Dist: rich>=15.0.0
Requires-Dist: watchdog>=6.0.0
Requires-Dist: websockets>=16.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.5.0; extra == 'dev'
Description-Content-Type: text/markdown

# odoo-hotupgrade

**Hot-upgrade Odoo modules the instant you save.** No manual "Apps → Upgrade", no container restarts, no context switch.

Save a `.py`, `.xml`, or `.js` file and watch the module upgrade + browser refresh happen automatically.

```bash
pip install odoo-hotupgrade
odoo-hotupgrade watch ./addons --proxy
```

Open `http://localhost:8070/web` — auto-reload active.

## How it works

On the **server side**, it upgrades Odoo modules in-place via XML-RPC or Docker exec. No container restart, no state loss — just the module you changed (plus dependents).

On the **client side**, it sends a WebSocket message that tells the browser to refresh after the upgrade completes.

```
File change → debounce (500ms) → classify change type
  ├─ CSS/JS/static assets → browser reload only (<500ms)
  ├─ Python method-only   → browser reload only (AST detected, <500ms)
  ├─ model/field/view     → hot upgrade module + dependents via RPC → browser reload (~2-6s)
  └─ __init__.py (root)   → full container restart → poll port → browser reload (~30s)
```

## Quickstart

```bash
# Auto-detect your Odoo setup and write odoo-hotupgrade.toml
odoo-hotupgrade init

# Watch with auto-inject proxy (no bookmarklet needed)
odoo-hotupgrade watch ./addons --proxy

# Watch using Docker exec instead of RPC
odoo-hotupgrade watch ./addons --proxy --docker

# Or run with just the config file
odoo-hotupgrade watch
```

## Change routing

| Change type | Server action | Latency |
|---|---|---|
| `*.js`, `*.css`, `static/**` | None (browser reload only) | <500ms |
| Python method (no model fields) | None (AST-detected safe) | <500ms |
| `models/*.py` field/model changes | Hot upgrade module + transitive dependents | ~2-6s |
| `views/*.xml`, `data/*.xml`, `security/*.xml` | Hot upgrade module | ~2-6s |
| `__manifest__.py` | Hot upgrade + rebuild dependency graph | ~2-6s |
| `__init__.py` (module root) | Container restart + poll | ~30s |

## Proxy mode

`--proxy` runs a local HTTP proxy that injects a WebSocket snippet into every HTML page. No browser extensions, no bookmarklet setup.

```bash
odoo-hotupgrade watch ./addons --proxy
```

Ports auto-detect (Docker mapping → port scan). Proxy defaults to `odoo-port + 1`.

### Alternatives

```bash
# Bookmarklet — drag to bookmarks bar
odoo-hotupgrade bookmarklet

# Console snippet — paste in dev tools
odoo-hotupgrade snippet
```

## Upgrade methods

| Method | Default? | Works with | How |
|---|---|---|---|
| **RPC** | ✅ (default) | Docker, bare metal, PyCharm, VM | XML-RPC to Odoo's `/web/dataset/call_kw` |
| **Docker** | `--docker` | Docker only | `docker exec` + Odoo CLI |

## Authentication

Admin credentials come from environment variables (never commit secrets):

```bash
export ODOO_ADMIN_USER="admin"
export ODOO_ADMIN_PASSWORD="your_password"
```

Fallback: `[odoo]` section in config file. Default: `admin` / `admin`.

## CLI reference

```
Usage: odoo-hotupgrade watch [OPTIONS] [ADDONS_PATHS]...

  --config, -c FILE     Config file (default: odoo-hotupgrade.toml)
  --container TEXT      Docker container name/ID
  --db TEXT             Odoo database name
  --ws-port INT         WebSocket port (default: 8765)
  --ws-host TEXT        WebSocket bind address (default: 127.0.0.1)
  --proxy               Auto-inject proxy mode
  --proxy-port INT      Proxy listen port (default: odoo-port + 1)
  --odoo-port INT       Odoo HTTP port (default: auto-detect)
  --docker              Use Docker exec (default: RPC)
  --no-live             Disable live status panel
```

## Configuration

```toml
[odoo]
addons_path = ["./addons", "./enterprise"]
database = "dev"
container = "odoo18_app"

[watch]
debounce_ms = 500
ignore = ["__pycache__", "*.pyc", ".git", "node_modules"]
websocket_port = 8765

[upgrade]
method = "rpc"       # or "docker"
max_depth = 1        # transitive dependency depth

[upgrade.rpc]
host = "localhost"
port = 8069
```

## Requirements

- Python 3.10+
- Docker (only for `--docker` upgrade method)
- Odoo 16+ (tested on 18)

## License

MIT
