Skip to content

Implement Odoo to PostgreSQL sync service - #10

Open
esmaeil-taheri wants to merge 25 commits into
odoonix:17.0from
esmaeil-taheri:taheri
Open

Implement Odoo to PostgreSQL sync service#10
esmaeil-taheri wants to merge 25 commits into
odoonix:17.0from
esmaeil-taheri:taheri

Conversation

@esmaeil-taheri

Copy link
Copy Markdown

Summary

Backend service that syncs Contacts, Products, Sale Orders and Sale Order Lines
from Odoo (XML-RPC) into PostgreSQL. Idempotent and re-runnable (upsert by odoo_id,
no duplicates), with per-record error isolation and a full audit trail in
sync_runs / sync_logs. Built with clean architecture + dependency injection.

How to run

docker compose up --build

Brings up Odoo + its DB, seeds Odoo test data, runs migrations, then the sync.

Local run:

cp .env.example .env
pip install -e .
alembic upgrade head
python -m app.main

Details in docs/USER.md.

How to run tests

pytest --cov=app

21 tests (entities, mappers, repositories, sync use case), ~77% coverage.

Key architecture decisions

  • Clean / hexagonal architecture — dependencies point inward
    (domain ← application ← infrastructure).
  • Adapter separated from service — Odoo access is isolated in OdooClient;
    swapping the ERP touches one adapter, not the business logic.
  • Repository over an IDBConnection port — swapping PostgreSQL for another
    DB touches one adapter.
  • odoo_id as primary key for synced tables → foreign keys align without id
    translation.
  • Idempotency — lookup by odoo_id, then update (exists) or save (new).
  • Per-record error isolation — each record runs in its own transaction; one
    failure is logged + counted and the batch continues (no full rollback).

More in docs/TECHNICAL.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant