cc-cli 1.0.0
Daddy Shell - Odoo Development CLI
License: MIT
Requires Python: >=3.10

# Odoo Workflow Automation Suite: CC

This repository provides a suite of tools to streamline and automate the workflow for Odoo development, focusing on tasks like project switching, database management, opening project tickets, fetching Odoo Git repositories, and interacting with Odoo SH. It includes a mix of CLI scripts and a VS Code extension, making your Odoo development process faster and more efficient.

## Features

- **Ticket Management**: Open project-related tickets directly from the command line.
- **Fetch Latest Odoo Repos**: Automatically fetch the latest Odoo Git repositories.
- **Project GitHub Management**: Open the current project’s GitHub page.
- **Database Management**:
  - Initialize a new database.
  - Copy or restore a database from a clone.
- **Launch Configuration**:
  - Switch between different Odoo projects using `launch.json`.
  - Change the current project's module in the `launch.json` file.
- **Odoo SH Management**: Open the current project’s Odoo SH environment, or switch to a different Odoo version in VS Code.


## How it works
The core logic comes from detecting your odoo codebase setup and finding the appropriate addons paths, enterprise, odoo/addons, odoo, design-themes.
> ### Odoo Codebase Structure 
>  Personally I have multiple odoo version codebase setup, so `cc` can detect all the different versions.
> 
> Others have it configured with one odoo code base and just `git checkout` the different versions.

As long as the `odoo-bin` file is detected, `cc` will work and update your `launch.json` correctly.

## CLI Commands

The `cc` CLI tool provides the following commands:

| Command | Description |
| :--- | :--- |
| `auto` | Automatically configures the tool by fetching settings for downloads and Odoo versions. |
| `cd` | Changes the current directory to the active project's path. |
| `cloc` | Gets code line count statistics for a project. |
| `configure` | Manually configures Odoo versions and the download path. |
| `copy` | Creates a copy of a database. |
| `db` | Manages the database parameter in the `launch.json` file for the active environment. |
| `env` | Manages project environments (add, list, remove). |
| `fetch` | Fetches all Git versions of the Odoo source code. |
| `github` | Opens the GitHub repository of the current or specified project. |
| `initdb` | Initializes a database from a zip file dump. |
| `module` | Updates the module list in the `launch.json` file for the active project. |
| `new` | Creates a new Odoo module from a template. |
| `restore` | Restores a database from a previously created copy. |
| `sh` | Opens the Odoo.sh page for the current or specified project. |
| `stat` | Shows the status of the project environments. |
| `switch` | Switches between different Odoo projects, updating the `launch.json` and `odoo.cfg` files. |
| `ticket` | Opens an Odoo ticket based on the current Git branch or manifest file. |
| `version` | Switches between different Odoo versions in Visual Studio Code. |

## VS Code Extension

The `cc-vscode-extension` provides a convenient way to use the `cc` CLI tool from within Visual Studio Code. Still a WIP.

### Features

- **Switch Project**: Switch between your Odoo projects with a quick pick menu.
- **Update Module**: Update the modules in your `launch.json` file with a multi-select quick pick menu.
- **Update Database**: Update the database in your `launch.json` file with a quick pick menu.

### Installation

1.  Install the CLI tool as described below.
2.  In VS Code, go to the Extensions view.
3.  Click on the "..." menu and select "Install from VSIX...".
4.  Navigate to the `cc-vscode-extension` directory and select the `.vsix` file.
5.  Reload VS Code.
6.  Set the `cc.cliPath` setting in your VS Code settings to the absolute path of the `cc` CLI folder.

## Installation

### Prerequisites

- Python/Pyenv Preferably
- Git
- Odoo Environment

### Installation
1.  **Clone the repository**:
    ```bash
    git clone git@github.com:chronofeldyx/cc.git
    ```
2.  **Auto Installer**:
    Run the installer and follow the wizard as needed:
    ```bash
    chmod +x installer.sh
    ./installer.sh
    ```
4.  **Configure Autocomplete**:
    Follow the instructions in the official `argcomplete` documentation to enable command-line completion.
    Add the following line to your `.bashrc` or `.zshrc`
    ```bash
    eval "$(register-python-argcomplete cc)"
   ```

## Usage

All of cc's data is stored in a sqlite database. This stores project information, current project paths, and previous project paths.

### Switch Projects

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



If the project alias does not exist in the storage, it will be created if found on your system.

### Manage Modules

```bash
cc module
```



A wizard will ask you which module to add based on the current project. Use `-r` to overwrite the module list entirely.

### Initialize a Database

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



A wizard will ask you to select the correct `.zip` file from your downloads folder.

### Copy a Database

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



This will create a new PostgreSQL database named `<database_name>-CC-COPY`.

### Restore a Database

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



This will restore the database from a copy named `<database_name>-CC-COPY`.
Currently deprecated
### Open Odoo.sh

```bash
cc sh
```

This will open the Odoo.sh page for the current project. Use `-u` to sync new projects.

### Open a Ticket

```bash
cc ticket
```


This will open the ticket from your terminal's Git branch or your current project's manifest file `odoo_task_ids` list.

### Open GitHub

```bash
cc github
```


This will open the GitHub repository of the project based on your terminal's current working directory.

### Create a New Module

```bash
cc new <module_name> -m <model_name_1> <model_name_2>
```

This will create a new module based on a template, with the option to create model files inside the new module.

### Open PSX Runbot

```bash
cc psx
```

This will open psx runbot for tests.