FastOdoo
FastAPI integration for Odoo via XML-RPC
FastOdoo is a Python library that provides a FastAPI-based REST interface for Odoo ERP systems via XML-RPC. It acts as a bridge between web applications and Odoo, offering ORM-like functionality for Python developers.
Features
- 🚀 FastAPI Integration: Ready-to-use REST API endpoints for common Odoo operations
- 🎯 ORM-like Interface: Familiar
env['model.name'].search()syntax similar to Odoo's Python ORM - 🔒 Secure Credentials: Built-in credential masking and flexible authentication providers
- ⚡ Performance Optimized: Intelligent caching with LRU cache and TTL support
- 🔗 Relation Handling: Automatic conversion of relational fields to RecordSet objects
- 🛠️ CLI Tools: Built-in command-line interface for project initialization
- 📋 Type Safety: Full type annotations and Pydantic integration
- 🔍 Extensible: Plugin-based credential providers (AWS Secrets Manager, etc.)
Quick Start
Installation
pip install fastodoo
Initialize a New Project
fastodoo init
This will create a new FastAPI application with FastOdoo integration and guide you through the setup process.
Manual Setup
- Create your FastAPI application:
from fastapi import FastAPI, Depends
from fastodoo import Odoo, Environment, odoo_router
app = FastAPI()
# Include pre-built CRUD endpoints (optional)
app.include_router(odoo_router, prefix="/odoo", tags=["Odoo CRUD"])
# Initialize Odoo connection
odoo = Odoo(version=18) # Specify your Odoo version
def get_env() -> Environment:
return odoo.env
@app.get("/contacts")
def get_contacts(env: Environment = Depends(get_env)):
contacts = env['res.partner'].search([], limit=5)
return {"contacts": contacts.mapped('name')}
- Configure your environment (.env file):
ODOO_URL=https://your-odoo-server.com
ODOO_DB=your_database_name
ODOO_USERNAME=your_username
ODOO_PASSWORD=your_password
- Run your application:
uvicorn main:app --reload
Core Concepts
ORM-like Interface
FastOdoo provides an ORM-like interface similar to Odoo's native Python ORM:
# Access models through environment
env = odoo.env
partners = env['res.partner'].search([('is_company', '=', True)])
# ORM-like field access with automatic relation handling
for partner in partners:
print(partner.name) # Direct field access
print(partner.parent_id.name) # Many2one relation access
# Use mapped() for bulk operations
names = partners.mapped('name')
parent_names = partners.mapped('parent_id.name')
CRUD Operations
# Create records
partner_id = env['res.partner'].create({
'name': 'New Contact',
'email': 'contact@example.com'
})
# Search and read
partners = env['res.partner'].search([('is_company', '=', True)], limit=10)
data = env['res.partner'].search_read([('active', '=', True)], ['name', 'email'])
# Update records
partner.write({'name': 'Updated Name'})
# Delete records
partner.unlink()
RecordSet Features
partners = env['res.partner'].browse([1, 2, 3, 4, 5])
# Length and iteration
print(len(partners)) # 5
for partner in partners:
print(partner.name)
# Slicing and indexing
first_partner = partners[0]
first_three = partners[:3]
# Field access and relations
names = partners.mapped('name')
countries = partners.mapped('country_id.name') # Traversing relations
Built-in REST API
FastOdoo includes pre-built REST endpoints for common operations:
GET /odoo/info- Get Odoo server informationGET /odoo/search_read/{model_name}- Search and read recordsGET /odoo/browse/{model_name}- Browse specific records by IDPOST /odoo/create/{model_name}- Create new recordsPUT /odoo/write/{model_name}- Update existing recordsDELETE /odoo/delete/{model_name}- Delete records
API Examples
# Get server info
curl http://localhost:8000/odoo/info
# Search partners
curl "http://localhost:8000/odoo/search_read/res.partner?fields=name,email&limit=5"
# Create a new partner
curl -X POST "http://localhost:8000/odoo/create/res.partner" \
-H "Content-Type: application/json" \
-d '{"name": "New Partner", "email": "new@example.com"}'
Advanced Configuration
Custom Credentials Provider
For production environments, you can implement custom credential providers:
from fastodoo.auth import CredentialsProvider, SecureCredential
import boto3
class AWSSecretsCredentialsProvider(CredentialsProvider):
def __init__(self, secret_name: str):
self.secret_name = secret_name
self.client = boto3.client('secretsmanager')
def get_credentials(self) -> Dict[str, str]:
secret = self.client.get_secret_value(SecretId=self.secret_name)
data = json.loads(secret['SecretString'])
return {
'url': data['odoo_url'],
'db': data['odoo_db'],
'username': data['odoo_username'],
'password': SecureCredential(data['odoo_password'])
}
# Use custom provider
odoo = Odoo(version=18, credentials_provider=AWSSecretsCredentialsProvider("odoo-creds"))
Caching Configuration
FastOdoo includes intelligent caching for better performance:
# Caching is automatically handled
partners = env['res.partner'].search([('is_company', '=', True)])
# Subsequent calls with same parameters will use cache
# Cache is invalidated automatically on write operations
partner.write({'name': 'Updated'}) # Cache cleared for this record
CLI Commands
FastOdoo includes a powerful CLI for project management:
# Initialize new project with interactive prompts
fastodoo init
# Initialize with specific options
fastodoo init --port 8080 --template --output my_app.py
# Show version
fastodoo version
# Get help
fastodoo --help
Project Structure
fastodoo/
├── fastodoo/
│ ├── __init__.py # Main exports and version
│ ├── odoo.py # Core Odoo client and ORM classes
│ ├── api.py # XML-RPC API mixins
│ ├── router.py # FastAPI router with CRUD endpoints
│ ├── auth.py # Authentication and credentials handling
│ ├── settings.py # Pydantic settings configuration
│ ├── exceptions.py # Custom exceptions
│ ├── cli.py # Command-line interface
│ └── template.py # FastAPI app template
├── pyproject.toml # Project configuration and dependencies
├── README.md # This file
└── LICENSE # MIT License
Requirements
- Python: 3.8+
- Odoo: 14.0+ (tested with versions 14-18)
- Dependencies:
fastapi- Web frameworkuvicorn[standard]- ASGI serverpydantic-settings- Configuration managementtyper[all]- CLI frameworkrich- Terminal formatting
Development Setup
- Clone the repository:
git clone https://github.com/your-username/fastodoo.git
cd fastodoo
- Create virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -e ".[dev]"
- Run linting:
ruff check
- Start development server:
python main.py
Important Notes
Odoo User Configuration
- Create a user in your Odoo instance without 2FA enabled. Two-factor authentication will cause XML-RPC authentication to fail.
- Ensure the user has appropriate permissions for the models you plan to access.
Security Considerations
- Always use HTTPS in production
- Store credentials securely (use credential providers, not plain text)
- FastOdoo automatically masks passwords in logs and debug output
- Validate and sanitize all user inputs in your endpoints
Performance Tips
- Use
search_read()instead ofsearch()+read()when possible - Leverage the built-in caching system
- Use
mapped()for bulk field access - Set appropriate limits on search operations
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
- Issues: GitHub Issues
- Documentation: GitHub README
FastOdoo - Bridge the gap between modern web development and Odoo ERP systems.
Metadata
Release files for fastodoo 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fastodoo-0.1.0.tar.gz | 87.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastodoo-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 109.8 kB
Release files / fastodoo-0.1.0.tar.gz
| Download URL | fastodoo-0.1.0.tar.gz |
|---|---|
| Size | 87.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9f1a6ea8a2ae03f456a6a382eeceecbc21348d29b869aec70dfe5d9bd7cb6270
|
|
BLAKE2b-256 checksum How to use checksums |
5e2923a8b37ed3c056957fa9a332a48d4b4022e6026d7363a0e7169032ceff80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.
Transparency logRelease files / fastodoo-0.1.0-py3-none-any.whl
| Download URL | fastodoo-0.1.0-py3-none-any.whl |
|---|---|
| Size | 22.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
90e4bae7b7e1ef4082f04603531ad6199c4de32a5a0ff2dec029fe5b220702d6
|
|
BLAKE2b-256 checksum How to use checksums |
11c0da36bca4483b187e95b6b20ade8826cf17614445dad177a8ad5d1fcb20e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.
Transparency log