Skip to content
Linux Running · 7 min read

Odoo Confirmed Every Booking and Never Wrote a Single Invoice

A coworking space ran bookings through Odoo Rental for months and had zero invoices. How I found it over the API and the plan to bill via InvoicePlane.

I asked a simple question about a coworking space I run the IT for: "the Odoo bookings don't get an invoice right now, do they?" I had a feeling. Turned out the feeling was too optimistic. Odoo had zero invoices. Not "a few missing". Zero. No drafts, no credit notes, nothing. Every booking had been confirmed, the room used, the key returned, and the order sat there on "To Invoice" forever.

Nobody noticed because Odoo looks busy. Bookings come in, confirmation mails go out, the calendar fills up. It all feels like a working system. It just never got to the part where money gets asked for.

TL;DR: Query sale.order with is_rental_order = True and look at invoice_status and invoice_count. If you see to invoice and 0 everywhere, and account.move is empty, your rental flow stops at confirmation. My fix is not to switch on Odoo accounting but to let the invoicing tool that already exists (self-hosted InvoicePlane) produce the invoice: booking confirmed in Odoo, invoice sent automatically, me in BCC. The decision is made; the build is the next step.

How to check in 30 seconds

I didn't click through the UI. The client's website already talks to Odoo over JSON-RPC (a small PHP helper in a WordPress theme pulls events and room availability), so I reused that helper inside the container. Same query in plain Python with XML-RPC looks like this:

import xmlrpc.client

URL, DB = "https://example.odoo.com", "example"
USER, KEY = "api@example.com", "YOUR_API_KEY"

common = xmlrpc.client.ServerProxy(f"{URL}/xmlrpc/2/common")
uid = common.authenticate(DB, USER, KEY, {})
odoo = xmlrpc.client.ServerProxy(f"{URL}/xmlrpc/2/object")

def call(model, method, args, kw=None):
    return odoo.execute_kw(DB, uid, KEY, model, method, args, kw or {})

orders = call("sale.order", "search_read",
    [[["is_rental_order", "=", True]]],
    {"fields": ["name", "state", "rental_status", "invoice_status",
                "invoice_count", "amount_total", "date_order"],
     "order": "id desc", "limit": 40})
for o in orders:
    print(o["name"], o["state"], o["rental_status"],
          o["invoice_status"], o["invoice_count"], o["amount_total"])

print("invoices:", call("account.move", "search_count", [[]]))
print(call("ir.module.module", "search_read",
    [[["name", "in", ["account", "sale_renting", "account_accountant"]]]],
    {"fields": ["name", "state"]}))

What came back, shape only (customer names removed):

S000xx  sale   returned  to invoice  0
S000xx  sale   returned  to invoice  0
S000xx  draft  draft     no          0
...
invoices: 0
account             installed
sale_renting        installed
account_accountant  installed

That's the whole story in three lines. Accounting modules installed, never used. All confirmed rentals at rental_status = returned (Odoo's states go reserved pickup, picked up return, returned returned) and invoice_status = to invoice. account.move count: 0. On top of that a few old orders that were never confirmed and just sit in draft.

Five real bookings were unbilled, plus one test booking of my own that obviously doesn't count. Whether any of those people paid some other way (cash, bank transfer to the IBAN in the confirmation mail, an invoice written by hand somewhere) Odoo can't tell you. That's the first thing to ask the humans before you generate anything retroactively. In this case the answer was: those were handled manually already, leave them alone.

Why not just turn on invoicing in Odoo

That was my first offer too: "want me to create draft invoices for the five, or build an automation that invoices on return?" Then I thought about where invoices for this company already live, and the answer changed.

The company that owns the coworking space already sends its outgoing invoices from a self-hosted InvoicePlane, with valid ZUGFeRD e-invoices (I wrote up that setup in ZUGFeRD e-invoices from self-hosted InvoicePlane). There's also a small internal web app that reads InvoicePlane, matches bank statements against invoices and builds the monthly package for the tax advisor. Invoices created in Odoo would:

  • open a second number range for the same company, which is exactly what you don't want
  • be invisible to the tax advisor export, the bank matching and the outgoing invoice list
  • need their own setup: Odoo accounting was never configured, no layout, no e-invoice. A whole separate project.

So Odoo stays the booking system and InvoicePlane stays the invoicing system. The glue sits in between.

The plan: booking confirmed, invoice goes out

This is the design as decided on 19.11. Not built yet, so read it as the plan:

  1. Someone confirms a booking. Either a customer books on the website, or staff create it in Odoo, or (new) staff create it from a small "create booking" page in the internal app, for requests that come in by email. Wherever it's created, it ends up as a confirmed rental order in Odoo.
  2. The internal app polls Odoo every 10 minutes for confirmed rental orders. It already runs its other syncs from cron on that rhythm, wrapped in flock so runs never overlap.
  3. For every order it hasn't seen, it creates an invoice in InvoicePlane in the company's existing number range: customer, room, day, the flat day price net plus 20% Austrian VAT, as a ZUGFeRD e-invoice like every other invoice.
  4. The invoice goes straight to the customer. I'm always in BCC, so every invoice that leaves also lands in my inbox.
  5. The app stores the mapping Odoo order to InvoicePlane invoice, so nothing ever gets billed twice.

Timing: the invoice goes out at confirmation, not after the room was used. For day offices that's the sensible order. The flip side: a cancellation now needs a credit note.

Who can create bookings in the internal app: three people, me included. Not everyone with a login.

The cron line will look like the ones that already exist on that box:

# /etc/cron.d/internal-app (illustrative, same pattern as the existing jobs)
*/10 * * * * appuser flock -n /var/lib/app/odoo-invoice.lock \
  sh -c 'cd /opt/app && set -a && . /etc/app/env && set +a && venv/bin/python -m app.odoo_invoice' \
  >> /var/lib/app/odoo-invoice.log 2>&1

If you prefer timers over cron for this kind of job, systemd timers do the same with better logging.

Gotcha: "send" is the one step that must never run twice

The internal app talks to InvoicePlane on the other server over SSH with a forced command: JSON on stdin, one JSON line back. Each request carries a UUID, and the receiving script keeps a state file per action under flock. A draft request with a known UUID just returns the earlier result. A send request with a known UUID is never executed again, and if a send was interrupted halfway, the result is "unclear" instead of a retry. A customer getting the same invoice twice is worse than a human checking one unclear case.

That's the same lesson as my cron job that uploaded one file 153 times: write the "done" marker right next to the side effect, and never let a flaky step decide whether the side effect repeats.

order S000xx  ->  invoice request (uuid A)  ->  draft created
              ->  send request    (uuid B)  ->  sent, B recorded
next run      ->  S000xx already mapped     ->  skip

Right now the existing code only allows "send" when a human clicked it on the review page. Auto-send at confirmation means changing that rule on purpose, for this one source, and keeping it narrow.

Gotcha: blocking a room without billing anyone

Bookings that come in by email need a way in, and sometimes a room just needs to be blocked: internal use, maintenance. A confirmed booking blocks the room in Odoo. The plan is a "blocker" booking that blocks the room too but never creates an invoice, recognized by a dedicated internal customer or a tag. The invoicing job skips it explicitly. Default should be "invoice", the exception has to be marked, not the other way round.

One thing I still have to verify before building: the website's booking form creates planning slots in Odoo and counts slots per day to show availability. Whether it also sees bookings created directly as rental orders in Odoo isn't confirmed yet. If not, someone can book a room online that's already taken, and that check has to be added first.

Gotcha: you often only have a name and an email

Web bookings usually come with name and email, no billing address. For an Austrian company that's fine for small amounts: an invoice up to 400 EUR gross can be a simplified small-amount invoice (Kleinbetragsrechnung), which doesn't need the customer's address. Day office bookings are well below that. If you're in another country, check your own threshold before you rely on this.

What I took away

  • "Confirmed" is not "billed". Check invoice_status on your orders, not the calendar.
  • Don't open a second invoicing system because the booking tool happens to have one. One number range per company, one place the tax advisor looks.
  • Make the bridge idempotent from day one: a stored mapping order to invoice, and a send step that refuses to run twice.
  • Ask the humans before billing old orders retroactively. Here they were already handled by hand.

Next step is the live check on the booking form, then building it. The SSH forced-command bridge stays the only way in to the invoicing box; if you build something similar, my SSH hardening checklist covers the server side.


Related posts