# Odoo Workflow Automation Suite: CC

A suite of tools to streamline Odoo development — project switching, database management, tickets, Odoo SH, and more. Includes a CLI and a VS Code extension.

## Features

* **Project Switching**: Switch between Odoo projects, auto-updating `launch.json` and `odoo.cfg`.
* **Multi-version Support**: Optionally maintain one active project per Odoo version simultaneously.
* **Module Management**: Interactively update the module list for the active project.
* **Database Management**: Initialize, copy, and restore databases.
* **Ticket & GitHub**: Open project tickets and GitHub repos from the terminal.
* **Odoo SH**: Open the Odoo SH environment for the current project.
* **Configuration Wizard**: Auto-detect Odoo versions, download paths, IDE, and more via `cc config`.

## How it works

CC detects your Odoo codebase by locating `odoo-bin` and resolving the correct addons paths (enterprise, odoo/addons, design-themes, project internals). As long as `odoo-bin` is found, `cc` will configure your `launch.json` correctly.

> **Multiple Odoo versions**: CC supports multiple codebases side by side (e.g. v16, v17, v18). Enable multi-version mode via `cc config` to keep one active project per version.

### Architecture (v3.0)

CC runs a background daemon (`cc daemon`) that listens on a Unix socket and handles all database writes. The CLI, web companion, and VSCode extension all send writes through it — eliminating SQLite write conflicts when multiple tools run at the same time.

```
CLI  ·  Web app  ·  VSCode extension
        ↓ JSON-RPC 2.0 (Unix socket)
      CC Daemon  (~/.cc-cli/cc.sock)
        ↓
      Service Layer  (src/cc/services/)
        ↓
      SQLite  (~/.cc-cli/cc_cli.db)
```

See [Under the Hood](/docs/internals.md) for the full architecture.

## CLI Commands

| Command     | Description                                                                                                                                                                                                   |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `cd`        | Change directory to the active project's path.                                                                                                                                                                |
| `cloc`      | Get code line count statistics for a project.                                                                                                                                                                 |
| `config`    | Configure CC settings and Odoo versions. Runs an interactive wizard with no args. Use `-l` to list values, `-v NAME PATH` to add a version, `-r NAME` to remove one, or `KEY VALUE` to set non-interactively. |
| `copy`      | Create a copy of a database.                                                                                                                                                                                  |
| `db`        | Manage the database parameter in `launch.json` for the active environment.                                                                                                                                    |
| `env`       | Manage project environments (add, list, remove).                                                                                                                                                              |
| `fetch`     | Fetch all Git versions of the Odoo source code.                                                                                                                                                               |
| `github`    | Open the GitHub repository for the current project.                                                                                                                                                           |
| `initdb`    | Initialize a database from a zip file dump.                                                                                                                                                                   |
| `module`    | Update the module list in `launch.json` for the active project.                                                                                                                                               |
| `new`       | Create a new Odoo module from a template.                                                                                                                                                                     |
| `psx`       | Open PSX runbot for tests.                                                                                                                                                                                    |
| `restore`   | Restore a database from a previously created copy.                                                                                                                                                            |
| `sh`        | Open the Odoo SH page for the current project.                                                                                                                                                                |
| `stat`      | Show the status of the active project environments.                                                                                                                                                           |
| `switch`    | Switch the active project, updating `launch.json` and `odoo.cfg`. Use `-s` to switch without opening the IDE. No args shows recent envs picker.                                                               |
| `time`      | View today's project switching log for timesheet generation. Use `-d YYYY-MM-DD` for a specific date, `--stop` to punch out, `--clear-flags` to review flagged spans.                                         |
| `pr`        | List your open GitHub PRs and open one in the browser, or create a PR with `cc pr <branch>`.                                                                                                                  |
| `doctor`    | Check CC data for issues with interactive fix suggestions. Use `--daemon` to check daemon health.                                                                                                             |
| `daemon`    | Manage the background daemon: `start`, `stop`, `restart`, `status`.                                                                                                                                           |
| `logs`      | Tail daemon log files. Use `rpc` for RPC-only traffic, `-f` to follow, `-l LEVEL` to filter by level.                                                                                                         |
| `backup`    | Named database snapshots: create, list, restore, delete.                                                                                                                                                      |
| `tunnel`    | SSH tunnel to Odoo.sh PostgreSQL for direct DB access.                                                                                                                                                        |
| `web`       | Start the CC companion web app.                                                                                                                                                                               |
| `ticket`    | Open an Odoo ticket from the current Git branch or manifest `odoo_task_ids`.                                                                                                                                  |
| `workspace` | Manage workspaces — group projects by Odoo version.                                                                                                                                                           |
| `intel`     | Manage the skill telemetry index — scan, add-repo, list-repos.                                                                                                                                                |
| `reindex`   | Walk new commits, run language packs, update skill tags.                                                                                                                                                      |

## Installation

**Prerequisites:** Python (Pyenv recommended), Git, an Odoo environment.

1. **Clone the repository:**

   ```bash
   git clone git@github.com:chronofeldyx/cc.git
   ```
2. **Run the installer:**

   ```bash
   chmod +x installer.sh
   ./installer.sh
   ```
3. **Enable autocomplete** — add to your `.bashrc` or `.zshrc`:

   ```bash
   eval "$(register-python-argcomplete cc)"
   ```

## Usage

All CC data is stored in a SQLite database at `~/.cc-cli/cc_cli.db`.

### Configure

```bash
cc config
```

Runs the interactive setup wizard — auto-detects Odoo versions and download path, prompts for IDE and other settings. Run `cc config -l` to inspect current values at any time.

### Switch Projects

```bash
cc switch <project_alias>
```

Switches the active project and opens it in your IDE. If the alias doesn't exist it will be discovered and created. Use `-s` to switch silently (no IDE open).

### Manage Modules

```bash
cc module
```

Interactive prompt to select which modules to add for the current project. Use `-r` to replace the module list entirely.

### Initialize a Database

```bash
cc initdb <database_name>
```

Prompts you to select a `.zip` dump from your downloads folder and initializes it as a new database.

### Copy a Database

```bash
cc copy <database_name>
```

Creates a new PostgreSQL database named `<database_name>-CC-COPY`.

### Restore a Database

```bash
cc restore <database_name>
```

Restores from a copy named `<database_name>-CC-COPY`.

### Open Odoo SH

```bash
cc sh
```

Opens the Odoo SH page for the current project. Use `-u` to sync new projects.

### Open a Ticket

```bash
cc ticket
```

Opens the ticket associated with the current Git branch or the project's manifest `odoo_task_ids`.

### Open GitHub

```bash
cc github
```

Opens the GitHub repository for the project in the current working directory.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cc.docs.chronocoder.org/readme.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
