Connecting Odoo

From the Odoo server on payment confirmation — an automated action with a short Python snippet, or a custom module overriding action_post. The key lives in ir.config_parameter, not in code, and bank_name comes from the bank journal.

Last updated: 2026-09-21

On this page

Principle

There is no Odoo-specific code in the app: the Odoo server (Community or Enterprise) posts from Python to POST /api/cheque-logs (= Create a cheque directly) when an account.payment is confirmed. The row is created confirmed, and bank_name is required and non-empty.

Path 1: automated action

Developer mode → Settings → Technical → Automated Actions → an action on account.payment “on creation and update” with the condition state == 'posted' → Python code:

python
bank = record.journal_id.bank_id.name or record.journal_id.name
if not bank:
    raise UserError("Bank name is required for Cheques Egypt")
payload = {
    "bank_name": bank,
    "cheque_type": "OUT" if record.payment_type == "outbound" else "IN",
    "recipient_name": record.partner_id.name,
    "amount": record.amount,
    "currency": record.currency_id.name,
    "cheque_date": str(record.date),
    "cheque_number": record.name,
    "external_source": "odoo",
    "external_id": "%s-%s" % (record.company_id.id, record.id),
}
api_key = env["ir.config_parameter"].sudo().get_param("cheques.api_key")
base_url = env["ir.config_parameter"].sudo().get_param("cheques.base_url")
requests.post(base_url + "/api/cheque-logs", json=payload,
              headers={"X-API-KEY": api_key, "Accept": "application/json"}, timeout=15)

Path 2: custom module

Override action_post() on account.payment and make the same call after super(). The key in ir.config_parameter (cheques.api_key · cheques.base_url), not in code — so rotation happens from the UI.

Field map

Odoo Cheque Note
partner_id.name recipient_name
amount amount
currency_id.name currency
date cheque_date str() yields YYYY-MM-DD
name cheque_number or the cheque number from the payment method if different
journal_id.bank_id.name bank_name required — if empty, stop; an empty string is rejected with 422
payment_type cheque_type outboundOUT · inboundIN
company_id + id external_id idempotency key

Common problems

  • 422 “bank name required” — the journal has no bank linked; link it or use the journal name.
  • Nothing arrives — the Odoo server cannot reach the Cheques server (firewall/outbound); test with curl from the Odoo server.
  • The action fires twice — “on creation and update” without the state condition; external_id turns the second call into 200 reused.
اطلب نسختك التجريبية مجانًا