Metadata-Version: 2.4
Name: odoo-easy
Version: 0.1.0
Summary: Lightweight Python wrapper for the Odoo XML-RPC API
License-Expression: MIT
Project-URL: Homepage, https://github.com/atovoman/odoo-easy
Project-URL: Repository, https://github.com/atovoman/odoo-easy
Project-URL: Issues, https://github.com/atovoman/odoo-easy/issues
Keywords: odoo,xmlrpc,erp,api,wrapper
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
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 :: Software Development :: Libraries
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# odoo-easy

A lightweight Python wrapper for the Odoo XML-RPC API. Stop writing boilerplate — connect and query Odoo in 3 lines.

## Installation

```bash
pip install odoo-easy
```

## Quick Start

```python
from odoo_connect import OdooClient

odoo = OdooClient("https://mycompany.odoo.com", "my-database")
odoo.login("admin@example.com", "your-password")

# List products
products = odoo.search_read("product.template", fields=["name", "list_price"])
```

## Usage

### Connect

```python
from odoo_connect import OdooClient

odoo = OdooClient("https://mycompany.odoo.com", "my-database")
odoo.login("admin@example.com", "your-password")
```

### Search records

```python
# Get all IDs
ids = odoo.search("product.template")

# With filters
ids = odoo.search("product.template", filters=[["type", "=", "product"]])

# With limit
ids = odoo.search("product.template", limit=10)
```

### Search and read in one call

```python
products = odoo.search_read(
    "product.template",
    filters=[["sale_ok", "=", True]],
    fields=["name", "list_price", "categ_id"],
    limit=50
)
# Returns: [{"id": 1, "name": "My Product", "list_price": 99.0, ...}, ...]
```

### Read by IDs

```python
records = odoo.read("res.partner", ids=[1, 2, 3], fields=["name", "email"])
```

### Create a record

```python
new_id = odoo.create("product.template", {
    "name": "New Product",
    "list_price": 49.99,
    "type": "product",
})
print(f"Created product with ID: {new_id}")
```

### Update records

```python
odoo.write("product.template", ids=[1, 2, 3], values={
    "list_price": 59.99
})
```

### Delete records

```python
odoo.unlink("product.template", ids=[99])
```

### Count records

```python
total = odoo.count("product.template", filters=[["active", "=", True]])
print(f"Total active products: {total}")
```

### Inspect model fields

```python
fields = odoo.get_fields("product.template", attributes=["string", "type"])
```

### Get server version

```python
info = odoo.version()
print(info)  # {'server_version': '18.0', ...}
```

## Error Handling

```python
from odoo_connect import OdooClient, OdooAuthError, OdooError

try:
    odoo = OdooClient("https://mycompany.odoo.com", "my-database")
    odoo.login("wrong@example.com", "badpassword")
except OdooAuthError as e:
    print(f"Authentication failed: {e}")
except OdooError as e:
    print(f"Odoo error: {e}")
```

## Compatibility

- Python 3.8+
- Odoo 14, 15, 16, 17, 18

## License

MIT
