Metadata-Version: 2.4
Name: cli-anything-dolibarr
Version: 1.0.0
Summary: CLI tool for Dolibarr ERP/CRM REST API management
Author: CLI Anything
License-Expression: MIT
Project-URL: Repository, https://github.com/zswll2/cli-dolibarr
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: System Administrators
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click>=8.0
Requires-Dist: requests>=2.25
Dynamic: license-file

# cli-anything-dolibarr

A stateful command-line interface for managing Dolibarr ERP/CRM via its REST API. Supports third parties, products, invoices, orders, proposals, stock movements, warehouses, projects, tasks, and more.

## Installation

```bash
pip install -e /path/to/agent-harness
```

## Configuration

```bash
cli-anything-dolibarr config init
```

Or set environment variables:

```bash
export DOLIBARR_URL="https://your-dolibarr.example.com/api/index.php"
export DOLIBARR_API_KEY="your_api_key"
```

## Usage

### Third Parties (Customers/Companies)

```bash
# List all third parties
cli-anything-dolibarr thirdparties list

# Get a specific third party
cli-anything-dolibarr thirdparties get 42

# Create a third party (required: name)
cli-anything-dolibarr thirdparties create --name "Acme Corp"

# Update a third party
cli-anything-dolibarr thirdparties update 42 --town "New York" --phone "+1234567890"

# Delete a third party
cli-anything-dolibarr thirdparties delete 42
```

### Products

```bash
# List products
cli-anything-dolibarr products list

# Get a specific product
cli-anything-dolibarr products get 7

# Create a product (required: ref, label)
cli-anything-dolibarr products create --ref "PROD-001" --label "Widget A"

# Update a product
cli-anything-dolibarr products update 7 --description "Updated description"

# Delete a product
cli-anything-dolibarr products delete 7
```

### Invoices

```bash
# List invoices
cli-anything-dolibarr invoices list

# Get a specific invoice
cli-anything-dolibarr invoices get 15

# Create an invoice (required: socid)
cli-anything-dolibarr invoices create --socid 42

# Update an invoice
cli-anything-dolibarr invoices update 15 --note "Payment pending"

# Delete an invoice
cli-anything-dolibarr invoices delete 15
```

### Orders

```bash
# List orders
cli-anything-dolibarr orders list

# Get a specific order
cli-anything-dolibarr orders get 23

# Create an order (required: socid, date)
cli-anything-dolibarr orders create --socid 42 --date "2026-01-15"

# Update an order
cli-anything-dolibarr orders update 23 --note "Expedited shipping"

# Delete an order
cli-anything-dolibarr orders delete 23
```

### Proposals

```bash
# List proposals
cli-anything-dolibarr proposals list

# Get a specific proposal
cli-anything-dolibarr proposals get 31

# Create a proposal (required: socid)
cli-anything-dolibarr proposals create --socid 42

# Update a proposal
cli-anything-dolibarr proposals update 31 --note "Revised terms"

# Delete a proposal
cli-anything-dolibarr proposals delete 31
```

### Stock Movements

```bash
# List stock movements
cli-anything-dolibarr stockmovements list

# Stock in (type=3, positive qty)
cli-anything-dolibarr stockmovements create --product-id 7 --warehouse-id 1 --qty 50

# Stock out (type=2, negative qty)
cli-anything-dolibarr stockmovements create --product-id 7 --warehouse-id 1 --qty -10
```

### Warehouses

```bash
# List warehouses
cli-anything-dolibarr warehouses list

# Get a specific warehouse
cli-anything-dolibarr warehouses get 1

# Create a warehouse (required: label)
cli-anything-dolibarr warehouses create --label "Main Warehouse"

# Update a warehouse
cli-anything-dolibarr warehouses update 1 --town "Shanghai"

# Delete a warehouse
cli-anything-dolibarr warehouses delete 1
```

### Projects

```bash
# List projects
cli-anything-dolibarr projects list

# Get a specific project
cli-anything-dolibarr projects get 5

# Create a project (required: title)
cli-anything-dolibarr projects create --title "Website Redesign"

# Update a project
cli-anything-dolibarr projects update 5 --description "Phase 2 started"

# Delete a project
cli-anything-dolibarr projects delete 5
```

### Tasks

```bash
# List tasks
cli-anything-dolibarr tasks list

# Get a specific task
cli-anything-dolibarr tasks get 12

# Create a task (requires project context)
cli-anything-dolibarr tasks create --title "Design mockups" --project-id 5

# Update a task
cli-anything-dolibarr tasks update 12 --progress 75

# Delete a task
cli-anything-dolibarr tasks delete 12
```

## Global Options

| Option          | Description                        |
|-----------------|------------------------------------|
| `--json`        | Output in JSON format              |
| `--csv`         | Output in CSV format               |
| `--url`         | Override Dolibarr API URL          |
| `--api-key`     | Override API key                   |
| `--limit N`     | Limit results to N items           |
| `--verify`      | Enable SSL certificate verification|

```bash
# Example: JSON output with limit
cli-anything-dolibarr products list --json --limit 5

# Example: CSV output
cli-anything-dolibarr invoices list --csv

# Example: Override URL and API key
cli-anything-dolibarr thirdparties list --url "https://your-dolibarr.example.com/api/index.php" --api-key "your_api_key"
```

## REPL Mode

Start an interactive session for repeated commands without re-authenticating:

```bash
cli-anything-dolibarr repl
```

Inside the REPL, use commands directly:

```
dolibarr> thirdparties list
dolibarr> products get 7
dolibarr> exit
```

## Environment Variables

| Variable            | Description                          |
|---------------------|--------------------------------------|
| `DOLIBARR_URL`      | Full API URL (e.g., `https://your-dolibarr.example.com/api/index.php`) |
| `DOLIBARR_API_KEY`  | API key from Dolibarr user settings  |
| `DOLIBARR_VERIFY_SSL`| Set to `1` or `true` to verify SSL  |

## SQL Filters

Use the `--sql-filter` option to apply advanced filters on list commands:

```bash
# Filter by name pattern
cli-anything-dolibarr thirdparties list --sql-filter "(t.name:like:'Acme%')"

# Filter by date range
cli-anything-dolibarr invoices list --sql-filter "(t.datec:>=:'2026-01-01')"

# Combined filters
cli-anything-dolibarr products list --sql-filter "(t.toselect:=:1) and (t.status:=:1)"

# IN operator
cli-anything-dolibarr orders list --sql-filter "(t.status:IN:1,2,3)"
```

Operators: `:=`, `:like:`, `:<`, `:>`, `:<=`, `:>=`, `:!=`, `:IN:`, `:NOTIN:`

## SSL Verification

By default, SSL verification is **disabled** (`--no-verify`) to support self-signed certificates common in self-hosted Dolibarr installations. To enable verification:

```bash
cli-anything-dolibarr --verify thirdparties list
```

Or set the environment variable:

```bash
export DOLIBARR_VERIFY_SSL="true"
```
