Common utilities and shared code for PRS microservices
Project description
PRS Commons
A Python library containing common utilities and shared code for PRS microservices, including a high-level Odoo RPC client.
📖 Documentation | 🐛 Issue Tracker | 📦 PyPI
Features
- Odoo RPC Client: High-level client for interacting with Odoo's XML-RPC API
- Type Annotations: Full type hints for better IDE support
- Singleton Pattern: Single connection management
- Environment Variable Support: Easy configuration via
.envfiles
Installation
From PyPI (Recommended)
pip install prs-commons
From Source (Development Only)
For development or contributing to the project:
For development, clone and install in editable mode:
git clone https://<token>@github.com/IshaFoundationIT/prs-facade-common.git
cd prs-facade-common
pip install -e ".[dev]" # Install with development dependencies
From Private Package Repository
Add your private package repository to pip configuration and install:
# Configure pip to use your private repository
pip config set global.extra-index-url https://your.private.registry.com/simple/
# Install the package
pip install prs-commons
Quick Start
Odoo RPC Client
from prs_commons.odoo.rpc_client import OdooRPClient
from dotenv import load_dotenv
# Initialize the client (singleton)
client = OdooRPClient()
# Search for records
try:
# Search for active partners
domain = [('is_company', '=', True), ('active', '=', True)]
fields = ['id', 'name', 'email']
partners = client.search_read('res.partner', domain, fields=fields)
# Create a new record
new_partner_id = client.create_record('res.partner', {
'name': 'John Doe',
'email': 'john@example.com',
'is_company': False
})
# Update a record
client.write_record('res.partner', [new_partner_id], {
'email': 'john.doe@example.com'
})
except Exception as e:
print(f"Error: {e}")
Configuration
Create a .env file in your project root:
ODOO_HOST=your-odoo-host.com
ODOO_DB=your_database
ODOO_LOGIN=your_email@example.com
ODOO_PASSWORD=your_password
Documentation
For full documentation, please see the API Reference.
Contributing
Contributions are welcome! Please read our Contributing Guide for details.
Development
Prerequisites
- Python 3.11+
- Poetry (recommended) or pip
Setup
-
Clone the repository:
git clone https://<token>@github.com/IshaFoundationIT/prs-facade-common.git cd prs-facade-common
-
Install dependencies:
# Using Poetry poetry install --with dev # Or using pip pip install -e ".[dev]"
-
Install pre-commit hooks:
pre-commit install
Running Tests
# Run all tests
pytest
# Run with coverage report
pytest --cov=prs_commons --cov-report=term-missing
Publishing New Versions
Prerequisites
-
Set up your
~/.pypircfile with your GitHub token:[distutils] index-servers = github [github] repository = https://upload.pypi.org/legacy/ username = __token__ password = your_github_token_here
Replace
your_github_token_herewith a GitHub Personal Access Token withwrite:packagesscope. -
Update the version in
pyproject.toml -
Build the package:
python -m build
-
Publish to GitHub Package Registry:
python -m twine upload --repository github dist/*
Contributing
- Create a feature branch
- Make your changes
- Run tests and pre-commit checks
- Submit a pull request
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prs_commons-0.2.0.tar.gz.
File metadata
- Download URL: prs_commons-0.2.0.tar.gz
- Upload date:
- Size: 8.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c21e1fa8fa35d6c72fefdcc875dadeefd3d78214db5b69f5538d3d02b8e89076
|
|
| MD5 |
d327b3c83aa44c857484c4d5f9b26ed7
|
|
| BLAKE2b-256 |
342034df6e205831b7662667f5fde78ebe32f575affd5be7f2b1519eee965ae9
|
File details
Details for the file prs_commons-0.2.0-py3-none-any.whl.
File metadata
- Download URL: prs_commons-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fe67046484025acda27c12336609abe19203b5f534e0f9b68cd3b09a58922c5
|
|
| MD5 |
9022791a6f62786cce8d2651a57b324d
|
|
| BLAKE2b-256 |
8a1d405c10c19156ef95788db2c831d3dbbe1ca5e66963cab6a08e1b4cb0d910
|