Metadata-Version: 2.4
Name: odooquickrun
Version: 1.0.5
Summary: Runner tool to run Odoo project using pew virtualenvs
Home-page: https://github.com/phuctranfxvn/odooquickrun
Author: Phuc (Tran Thanh)
Author-email: phuctran.fx.vn@gmail.com
License: MIT
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENCE
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: requires-python
Dynamic: summary

# odooquickrun

A simple command-line tool to manage Odoo projects using a **pew-managed virtual environment**.

## 📦 Installation

Install directly from GitHub or your local source:

```bash
pip install odooquickrun
```

## ❌ Uninstallation

To remove the tool:

```bash
pip uninstall odooquickrun
```

## 🚀 Usage

**Prerequisite:** Ensure you have created and activated the `pew` virtual environment for your project before running these commands.

### 📋 Init a New Project

Scaffold a new Odoo project with the standard layout and clone Odoo source code.
```bash
odooquickrun init <project_name> [-v <version>] [--no-squash]
```
* `-v` / `--version`: Odoo version branch to clone (default: `19.0`).
* `--no-squash`: Clone full git history instead of shallow (depth=1).

This creates:
```text
<project_name>/
├── addons/requirements.txt
├── config/dev.conf
├── project/requirements.txt
├── odoo/              ← cloned from GitHub
└── .gitignore
```

---

### 🖥️ Odoo Server Operations

**Start Odoo**
```bash
odooquickrun start
```

**Start in Debug Mode**
Running with `debugpy` on port `5678`.
```bash
odooquickrun debug
```

**Upgrade Modules**
Update specific modules in a database.
```bash
odooquickrun upgrade -d <db_name> -m <module1,module2,...>
```
* `-d`: Database name.
* `-m`: Comma-separated list of modules to upgrade.

### 🗄️ Database Operations

You can manage your local PostgreSQL databases directly using the `db` command.

> **Note:** The default database port is `5432`. You can specify a custom port for any of the commands below using the `--db-port <port>` option.

#### 1. Database Management

**List all databases** (shows owner and size)
```bash
odooquickrun db info
```

**Drop databases**
Delete one or multiple databases.
```bash
odooquickrun db drop <db1,db2,...> [options]
```
* `<db1,db2,...>`: Comma-separated list of database names (e.g., `test_db,demo_db`).
* `-f` / `--force`: Skip confirmation prompt (useful for automation).

#### 2. User (Role) Management

**List all users** (shows superuser & createdb status)
```bash
odooquickrun db list_users
```

**Create a new user**
Creates a user with `CREATEDB` permission (required for Odoo to create its own databases).
```bash
odooquickrun db create_user <username> <password>
```

**Drop a user**
Permanently delete a postgres user/role.
```bash
odooquickrun db drop_user <username> [-f]
```

#### 3. Database Cleaning

**Execute a SQL cleaning script**
Run a `.sql` file against a database (e.g., for data anonymization or cleanup).
```bash
odooquickrun db clean <database> -f <path/to/file.sql> [--force]
```
* `-f` / `--file`: Path to the SQL file to execute (required).
* `--force`: Skip confirmation prompt.

---

## 📁 Project Structure

This CLI is designed to be used inside a [pew](https://github.com/berdario/pew)-managed virtualenv containing an Odoo project, structured as follows:

```text
<project_root>/
│
├── odoo/                             # Odoo core (source code)
│
├── addons/
│   ├── custom_3rd_party_addons_1/    # 3rd party modules (OCA, ...)
│   │   ├── module_a/
│   │   ├── module_b/
│   ├── custom_3rd_party_addons_2/
│   │   ├── module_c/
│   │   ├── module_d/
│   ...
│
├── project/                          # Customized modules for project
│   ├── project_module_1/
│   ├── project_module_2/
│   ├── project_module_3/
│
├── config/
    ├── local.conf (or dev.conf)
```

#### Notes:
- You don't need to specify the `addons_path` in the `.conf` file; the script will automatically calculate and prepare it for you based on the folder structure above.

## 🔄 odoo.sh Project Support

`odooquickrun` **automatically detects** whether your project uses the standard layout or an **odoo.sh** setup.

### Detection Logic

- If `config.sh` exists in the project root → **odoo.sh mode**
- Otherwise → **regular mode** (standard layout)

### odoo.sh Project Structure

```text
<project_root>/
├── config.sh                  # Project configuration (REQUIRED for detection)
├── odoo.sh                    # Original launcher (optional, not used by odooquickrun)
├── Makefile                   # Optional
└── <project_dirs>/            # Custom modules (referenced by PROJECT_DIRS)
    ├── module_a/
    └── module_b/
```

### config.sh Variables

| Variable | Description | Default |
|---|---|---|
| `VERSION` | Odoo version (e.g., `17.0`) | Required |
| `PROJECT` | Project name | Directory name |
| `PROJECT_DIRS` | Path(s) to custom addons | — |
| `VENV` | Virtualenv name | `venv-odoo{VERSION}` |
| `DB` | Database name | `v{VERSION}{e/c}_{PROJECT}` |
| `IP` | Listen address | `127.0.0.1` |
| `HTTP_PORT` | Listen port | `8069` |
| `ODOO_ROOT_DIR` | Root dir for Odoo source | `~/code/odoo` |
| `EXTRA_ADDONS_PATH` | Additional addons paths | — |
| `EXTRA_PARAMS` | Extra odoo-bin parameters | — |
| `ENTERPRISE` | Enable enterprise (`1`/`0`) | `1` |

---

## 🛠 Requirements

- Python 3.7+
- `pew` for managing virtual environments
- `odoo-bin` available in your Odoo project path
- PostgreSQL client tools (`psql`) installed and added to PATH

## 👤 Author

**Phúc Trần Thanh (Felix)**

* 📧 Email: [phuctran.fx.vn@gmail.com](mailto:phuctran.fx.vn@gmail.com)
* 🐙 Github: [@phuctranfxvn](https://github.com/phuctranfxvn)
