Skip to main content

A zen-like, modern async Python library for Odoo RPC with type safety, transactions, caching, and AI-powered MCP integration

Project description

Zenoo RPC

A zen-like, modern async Python library for Odoo RPC with type safety, AI integration, and MCP protocol support

Python 3.8+ PyPI version Python versions License: MIT CI Coverage Documentation Code style: black Ruff Downloads GitHub stars

๐Ÿ“š Documentation โ€ข ๐Ÿš€ Quick Start โ€ข ๐Ÿ“ฆ PyPI โ€ข ๐Ÿ› Issues โ€ข ๐Ÿ’ฌ Discussions

๐Ÿš€ Why Zenoo RPC?

Zenoo RPC is a next-generation Python library designed to replace odoorpc with modern Python practices and superior performance. Built from the ground up with async/await, type safety, and developer experience in mind.

"Zen" - Simple, elegant, and intuitive API design
"oo" - Object-oriented with Odoo integration
"RPC" - Remote Procedure Call excellence

โœจ Key Features

  • ๐Ÿ”„ Async-First: Built with asyncio and httpx for high-performance concurrent operations
  • ๐Ÿ›ก๏ธ Type Safety: Full Pydantic integration with IDE support and runtime validation
  • ๐ŸŽฏ Fluent API: Intuitive, chainable query builder that feels natural
  • ๐Ÿค– AI-Powered: Natural language queries, error diagnosis, and code generation
  • ๐Ÿ”Œ MCP Integration: Full Model Context Protocol support for AI assistants (Claude Desktop, ChatGPT)
  • โšก Performance: Intelligent caching, batch operations, and optimized RPC calls
  • ๐Ÿ”ง Modern Python: Leverages Python 3.8+ features with proper type hints
  • ๐Ÿ“ฆ Clean Architecture: Well-structured, testable, and maintainable codebase
  • ๐Ÿ”„ Transaction Support: ACID-compliant transactions with rollback capabilities
  • ๐Ÿš€ Batch Operations: Efficient bulk operations for high-performance scenarios
  • ๐Ÿ” Retry Mechanisms: Intelligent retry with exponential backoff and circuit breaker
  • ๐Ÿ’พ Intelligent Caching: TTL/LRU caching with Redis support

๐Ÿค” Problems with odoorpc

  • Synchronous only: No async support for modern Python applications
  • No type safety: Raw dictionaries and lists without validation
  • Chatty API: Multiple RPC calls for simple operations (search + browse)
  • Complex relationship handling: Requires knowledge of Odoo's tuple commands
  • Poor error handling: Generic exceptions without context
  • No caching: Repeated calls for the same data

๐ŸŽฏ Zenoo RPC Solutions

# odoorpc (old way)
Partner = odoo.env['res.partner']
partner_ids = Partner.search([('is_company', '=', True)], limit=10)
partners = Partner.browse(partner_ids)  # Second RPC call!

# Zenoo RPC (modern way)
async with ZenooClient("localhost", port=8069) as client:
    await client.login("demo", "admin", "admin")

    partners = await client.model(ResPartner).filter(
        is_company=True
    ).limit(10).all()  # Single RPC call with type safety!

๐Ÿ“ฆ Installation

From PyPI (Recommended)

pip install zenoo-rpc

With Optional Dependencies

# For Redis caching support
pip install zenoo-rpc[redis]

# For AI features (Gemini, OpenAI, Anthropic)
pip install zenoo-rpc[ai]

# For MCP integration (AI assistants)
pip install zenoo-rpc[mcp]

# For development
pip install zenoo-rpc[dev]

# All features
pip install zenoo-rpc[ai,mcp,redis,dev]

From Source

git clone https://github.com/tuanle96/zenoo-rpc.git
cd zenoo-rpc
pip install -e .

๐Ÿ—๏ธ Architecture

Zenoo RPC follows modern Python best practices with a clean, modular architecture:

src/zenoo_rpc/
โ”œโ”€โ”€ client.py              # Main async client
โ”œโ”€โ”€ transport/             # HTTP transport layer
โ”œโ”€โ”€ models/                # Pydantic models
โ”œโ”€โ”€ query/                 # Fluent query builder
โ”œโ”€โ”€ cache/                 # Async caching layer
โ”œโ”€โ”€ exceptions/            # Structured exception hierarchy
โ”œโ”€โ”€ transaction/           # Transaction management
โ”œโ”€โ”€ batch/                 # Batch operations
โ”œโ”€โ”€ retry/                 # Retry mechanisms
โ”œโ”€โ”€ ai/                    # AI-powered features
โ”œโ”€โ”€ mcp_server/            # Model Context Protocol server
โ”œโ”€โ”€ mcp_client/            # Model Context Protocol client
โ””โ”€โ”€ utils/                 # Utilities and helpers

๐Ÿš€ Quick Start

import asyncio
from zenoo_rpc import ZenooClient
from zenoo_rpc.models.common import ResPartner

async def main():
    async with ZenooClient("https://your-odoo-server.com") as client:
        # Authenticate
        await client.login("your_database", "your_username", "your_password")

        # Type-safe queries with IDE support
        partners = await client.model(ResPartner).filter(
            is_company=True,
            name__ilike="company%"
        ).limit(10).all()

        # Access fields with full type safety
        for partner in partners:
            print(f"Company: {partner.name} - Email: {partner.email}")

        # Transaction management (optional)
        await client.setup_transaction_manager()
        async with client.transaction():
            partner = await client.model(ResPartner).filter(
                is_company=True
            ).first()
            if partner:
                print(f"Processing: {partner.name}")
                # Modifications are committed automatically on context exit

if __name__ == "__main__":
    asyncio.run(main())

๐Ÿ”Œ MCP Integration - AI Assistant Support

Zenoo RPC provides full Model Context Protocol (MCP) support, enabling seamless integration with AI assistants like Claude Desktop, ChatGPT, and other MCP-compatible tools.

๐Ÿค– Use with Claude Desktop

Configure Claude Desktop to use Zenoo RPC as an MCP server:

// ~/.config/claude/claude_desktop_config.json
{
  "mcpServers": {
    "odoo": {
      "command": "python",
      "args": ["-m", "zenoo_rpc.mcp_server.cli"],
      "env": {
        "ODOO_URL": "http://localhost:8069",
        "ODOO_DATABASE": "demo",
        "ODOO_USERNAME": "admin",
        "ODOO_PASSWORD": "admin"
      }
    }
  }
}

Now Claude can directly interact with your Odoo data:

User: "Find all technology companies in Vietnam and analyze their sales"

Claude automatically:
1. Searches for companies with filters: is_company=True, country='Vietnam', name contains 'tech'
2. Retrieves their sales orders and analyzes performance
3. Provides insights and recommendations

๐Ÿ› ๏ธ MCP Tools Available

  • search_records - Advanced search with complex filters
  • get_record - Retrieve specific records with relationships
  • create_record - Create new records with validation
  • update_record - Update existing records
  • delete_record - Delete records safely
  • complex_search - Advanced queries with Q objects
  • batch_operation - High-performance bulk operations
  • analytics_query - Data analysis and aggregation

๐Ÿš€ Installation with MCP

# Install with MCP support
pip install zenoo-rpc[mcp]

# Start MCP server
python -m zenoo_rpc.mcp_server.cli --transport stdio

๐ŸŽฏ Advanced Features

Lazy Loading with Type Safety

# Relationship fields are lazy-loaded automatically
partner = await client.model(ResPartner).get(1)
company = await partner.company_id  # Loaded on demand
children = await partner.child_ids.all()  # Lazy collection

Intelligent Caching

async with ZenooClient("localhost", port=8069) as client:
    await client.login("demo", "admin", "admin")

    # Setup cache manager
    await client.setup_cache_manager(backend="redis", url="redis://localhost:6379/0")

    # Cached queries
    partners = await client.model(ResPartner).filter(
        is_company=True
    ).cache(ttl=300).all()  # Cached for 5 minutes

Batch Operations

async with ZenooClient("localhost", port=8069) as client:
    await client.login("demo", "admin", "admin")

    # Setup batch manager
    await client.setup_batch_manager(max_chunk_size=100)

    # Efficient bulk operations
    async with client.batch() as batch:
        partners_data = [
            {"name": "Company 1", "email": "c1@example.com"},
            {"name": "Company 2", "email": "c2@example.com"},
        ]
        partners = await batch.create_many(ResPartner, partners_data)

Transaction Management

async with ZenooClient("localhost", port=8069) as client:
    await client.login("demo", "admin", "admin")

    # Setup transaction manager
    await client.setup_transaction_manager()

    # ACID transactions with rollback
    async with client.transaction() as tx:
        partner = await client.model(ResPartner).create({
            "name": "Test Company",
            "email": "test@example.com"
        })

        # If any error occurs, transaction is automatically rolled back
        await partner.update({"phone": "+1234567890"})
        # Committed automatically on successful exit

๐Ÿค– AI-Powered Features

Zenoo RPC includes cutting-edge AI capabilities powered by LiteLLM and Google Gemini:

async with ZenooClient("localhost", port=8069) as client:
    await client.login("demo", "admin", "admin")

    # Setup AI capabilities
    await client.setup_ai(
        provider="gemini",
        model="gemini-2.5-flash-lite",
        api_key="your-gemini-api-key"
    )

    # Natural language queries
    partners = await client.ai.query("Find all companies in Vietnam with revenue > 1M USD")

    # Intelligent error diagnosis
    try:
        result = await client.search("invalid.model", [])
    except Exception as error:
        diagnosis = await client.ai.diagnose(error)
        print(f"Problem: {diagnosis['problem']}")
        print(f"Solution: {diagnosis['solution']}")

    # Smart code generation
    model_code = await client.ai.generate_model("res.partner")

    # Performance optimization suggestions
    suggestions = await client.ai.suggest_optimization(query_stats)

    # Interactive AI chat
    response = await client.ai.chat("How do I create a Many2one field in Odoo?")

AI Features:

  • ๐Ÿ—ฃ๏ธ Natural Language Queries: Convert plain English to optimized Odoo queries
  • ๐Ÿ” Error Diagnosis: AI-powered error analysis with actionable solutions
  • ๐Ÿ—๏ธ Code Generation: Generate typed Python models from Odoo schemas
  • โšก Performance Optimization: AI suggestions for query and cache optimization
  • ๐Ÿ’ฌ Interactive Chat: Get expert advice on Odoo development

Installation with AI:

pip install zenoo-rpc[ai]

๐Ÿงช Development Status

Zenoo RPC is currently in Alpha stage with active development. The core architecture is stable and functional, but we're continuously improving based on community feedback.

Current Status

  • โœ… Core Features: Fully implemented and tested
  • โœ… Type Safety: Complete Pydantic integration
  • โœ… Async Operations: Full async/await support
  • โœ… Advanced Features: Caching, transactions, batch operations
  • โœ… Documentation: Comprehensive guides and examples
  • ๐Ÿ”„ Community: Growing user base and contributors
  • ๐Ÿ”„ Performance: Ongoing optimization efforts

Roadmap

  • Phase 1: Core transport layer and async client
  • Phase 2: Pydantic models and query builder foundation
  • Phase 3: Advanced features (caching, transactions, batch ops)
  • Phase 4: AI-powered features (natural language queries, error diagnosis, code generation)
  • Phase 5: Documentation and community adoption
  • Phase 6: Performance optimization and production hardening
  • Phase 7: Advanced AI features (predictive analytics, auto-optimization)
  • Phase 8: Plugin system and extensibility
  • Phase 9: GraphQL support and modern APIs

Production Readiness

Zenoo RPC is being used in production environments, but we recommend:

  • Testing: Thoroughly test in your specific environment
  • Monitoring: Implement proper logging and monitoring
  • Gradual Migration: Migrate from odoorpc incrementally
  • Community Support: Join our discussions for help and feedback

Compatibility

  • Python: 3.8, 3.9, 3.10, 3.11, 3.12
  • Odoo: 18.0 (tested) - other versions compatibility not yet verified
  • Operating Systems: Linux, macOS, Windows

๐Ÿค Contributing

We welcome contributions from the community! Whether you're fixing bugs, adding features, improving documentation, or sharing feedback, your contributions help make Zenoo RPC better for everyone.

Ways to Contribute

  • ๐Ÿ› Report Bugs: Use our issue templates
  • โœจ Request Features: Share your ideas in GitHub Discussions
  • ๐Ÿ“ Improve Documentation: Help us make the docs clearer and more comprehensive
  • ๐Ÿงช Write Tests: Increase test coverage and add edge cases
  • ๐Ÿ”ง Fix Issues: Pick up issues labeled good first issue or help wanted
  • ๐Ÿ’ก Share Examples: Contribute real-world usage examples

Quick Development Setup

# Clone the repository
git clone https://github.com/tuanle96/zenoo-rpc.git
cd zenoo-rpc

# Install development dependencies
pip install -e ".[dev,redis]"

# Install pre-commit hooks (recommended)
pre-commit install

# Run tests
pytest

# Run quality checks
ruff check .
black .
mypy src/zenoo_rpc

# Build documentation locally
mkdocs serve

Contribution Guidelines

Please read our Contributing Guide for detailed information about:

  • Code style and conventions
  • Testing requirements
  • Pull request process
  • Issue reporting guidelines
  • Community standards

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes with tests
  4. Run quality checks (pre-commit run --all-files)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to your branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Getting Help

๐Ÿ› ๏ธ Development

Want to contribute? Here's how to set up your development environment:

# Clone the repository
git clone https://github.com/tuanle96/zenoo-rpc.git
cd zenoo-rpc

# Install development dependencies
pip install -e ".[dev,redis]"

# Install pre-commit hooks (recommended)
pre-commit install

# Run tests
pytest

# Run quality checks
ruff check .
black .
mypy src/zenoo_rpc

๐Ÿ“š Documentation

๐Ÿ› Support

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Inspired by the need to modernize the Odoo Python ecosystem
  • Built on the shoulders of giants: httpx, pydantic, and asyncio
  • Thanks to the OCA team for maintaining odoorpc and showing us what to improve
  • Special thanks to all contributors and early adopters

Zenoo RPC: Because your Odoo integrations deserve modern Python! ๐Ÿโœจ

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zenoo_rpc-0.2.2.tar.gz (786.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zenoo_rpc-0.2.2-py3-none-any.whl (178.1 kB view details)

Uploaded Python 3

File details

Details for the file zenoo_rpc-0.2.2.tar.gz.

File metadata

  • Download URL: zenoo_rpc-0.2.2.tar.gz
  • Upload date:
  • Size: 786.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for zenoo_rpc-0.2.2.tar.gz
Algorithm Hash digest
SHA256 efeb905498876f9b16f82d193d6db49aa417fade1f96a2f6ab16f04e7c6e6363
MD5 ae10fcc7531684691b5e0659fb984503
BLAKE2b-256 fbf410e1b07709f973189da0df8174163f117039522e88b8f456b24b7664b223

See more details on using hashes here.

File details

Details for the file zenoo_rpc-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: zenoo_rpc-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 178.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for zenoo_rpc-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 43f994fd4c3f06c517a9430fa8134cef7cd9f7e0c35d5da5173e01956cdce04e
MD5 11527a200eaaa405e5ddba48cc207880
BLAKE2b-256 81a4bcfbd6c618ca1f3a8081c89892d0d67975dd3fdf4638e9be6fe641efc8d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page