Lightweight Odoo XML-RPC client with buit-in payroll novedades support
Project description
unergy-odoo
Lightweight Odoo XML-RPC client for Python. No Django required.
Installation
# Local install (editable)
pip install -e /path/to/unergy-odoo
# With uv
uv add /path/to/unergy-odoo
Configuration
Credentials are resolved from environment variables by default:
export ODOO_HOST="https://your-instance.odoo.com"
export ODOO_DB="your-database"
export ODOO_USERNAME="user@example.com"
export ODOO_PASSWORD="your-api-key"
Any constructor accepts explicit overrides that take priority over env vars:
odoo = Odoo("hr.payslip", host="https://...", db="mydb", username="u", password="p")
Usage
Odoo — model client
from unergy_odoo import Odoo
# Query records
payslips = Odoo("hr.payslip").filter(
fields=["name", "state", "employee_id"],
filter=[["state", "=", "done"]],
limit=50,
)
# Get a single record (raises Odoo.DoesNotExist if not found)
employee = Odoo("hr.employee").get(filter=[["identification_id", "=", "1234567890"]])
# Count
total = Odoo("hr.contract").count(filter=[["state", "=", "open"]])
# Create / update / delete
record_id = Odoo("res.partner").create({"name": "Acme", "email": "acme@example.com"})
Odoo("res.partner").update([record_id], {"phone": "+57 300 000 0000"})
Odoo("res.partner").delete([record_id])
OdooExplorer — read-only introspection
Useful for discovering models, fields, and relations without risking writes.
from unergy_odoo import OdooExplorer
explorer = OdooExplorer()
# Find models by keyword
explorer.search_models("payslip")
explorer.search_models("nomina")
# Inspect fields
explorer.model_fields("hr.payslip")
explorer.model_fields("hr.payslip", field_type="selection")
# Inspect relational fields only
explorer.model_relations("hr.payslip")
# Count records (with optional domain)
explorer.count_records("hr.payslip")
explorer.count_records("hr.contract", [["state", "=", "open"]])
# Fetch sample records
explorer.sample("hr.payslip", limit=2)
explorer.sample("hr.payslip", fields=["name", "state", "employee_id"])
OdooManager — base connection
Use directly when you need raw execute_kw access.
from unergy_odoo import OdooManager
mgr = OdooManager()
uid = mgr.authenticate()
result = mgr._exec(mgr.db, uid, mgr.password, "hr.payslip", "search_count", [[]])
Novedades (payroll attachments)
High-level dataclasses for registering hr.salary.attachment records in Odoo.
BonoGimnasio
from datetime import date
from unergy_odoo.novedades import BonoGimnasio
bono = BonoGimnasio(
identification="1234567890",
description="GIMNASIO JOHN DOE 2026-04-15 #10",
monthly_amount=80_000,
date_start=date(2026, 4, 1),
type_payment="second_half",
)
odoo_id = bono.register()
Viatico
from datetime import date
from unergy_odoo.novedades import Viatico
viatico = Viatico(
identification="1234567890",
description="Viático viaje Bogotá",
monthly_amount=150_000,
date_start=date(2026, 4, 1),
type_payment="first_half",
attachments=["soporte.pdf"], # str, Path, or file-like object
)
odoo_id = viatico.register()
# Fixed total amount (single payment)
viatico = Viatico(
identification="1234567890",
description="Viático viaje Medellín",
monthly_amount=0,
date_start=date(2026, 4, 1),
type_payment="monthly",
total_amount=300_000,
has_total_amount=True,
date_end=date(2026, 4, 30),
)
type_payment values
| Value | Quincena |
|---|---|
monthly |
Mensual |
first_half |
Primera quincena |
second_half |
Segunda quincena |
both_fortnight |
Ambas quincenas |
Adding new novedad types
Subclass NovedadBase, set DEDUCTION_TYPE, and override _payload() for any extra fields:
from dataclasses import dataclass, field
from unergy_odoo.novedades import NovedadBase
@dataclass
class AuxilioTransporte(NovedadBase):
DEDUCTION_TYPE: str = field(init=False, default="AUX_TRANSPORTE")
def _payload(self) -> dict:
return {}
Credential overrides per novedad
If you need different credentials for a specific novedad instance:
bono = BonoGimnasio(
...,
odoo_host="https://staging.odoo.com",
odoo_db="staging-db",
odoo_username="test@example.com",
odoo_password="staging-key",
)
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
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 unergy_odoo-0.2.0.tar.gz.
File metadata
- Download URL: unergy_odoo-0.2.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e2949d03d173a5c45123883df778e127e23fedba8f468c5432ebe0ddfa290fb
|
|
| MD5 |
1e654c5da98eff16589d04e8b3a2c7aa
|
|
| BLAKE2b-256 |
140d6971422dbcfb62f8d04742f9df8685120a03f2d9197496c58af444c8a46e
|
File details
Details for the file unergy_odoo-0.2.0-py3-none-any.whl.
File metadata
- Download URL: unergy_odoo-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93f23e89dbe2dc1b8293b3db69c8567129512da568c02dbc453d33402dc49249
|
|
| MD5 |
80c7257e179521e3a4770a1be975e2bb
|
|
| BLAKE2b-256 |
6364e1131259cc610d32336dc60dec52e311b7cb9686075ba51c66d7f54d886c
|