Skip to main content

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

unergy_odoo-0.3.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

unergy_odoo-0.3.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file unergy_odoo-0.3.0.tar.gz.

File metadata

  • Download URL: unergy_odoo-0.3.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for unergy_odoo-0.3.0.tar.gz
Algorithm Hash digest
SHA256 efde5b9be00ef476a07d20197ee9759a02b1a3e51e3299c7dfa9fa9925b97b89
MD5 7048642636ca773428c736ed6eb0850c
BLAKE2b-256 b1e0998cb5c36b9af1d1aac35c3b4d8df0ecb9cbcca3b588571a1286d1edecb4

See more details on using hashes here.

File details

Details for the file unergy_odoo-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: unergy_odoo-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for unergy_odoo-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90aa4d68ed5e98fbcd5c8b7ce227b8a7c069de5f5cb8f9cd636db7870b2f3b1d
MD5 cc1917702eadab480a9ddc78b8e94418
BLAKE2b-256 de61d8d7bfc130e381dd483d48c5a5f3cdfeca1902b1a3f4ab190e735afb9a31

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