Skip to content

New Odoo invoice PDFs to your accountant

Who this is for: finance teams who invoice in Odoo and send every invoice to an accountant or a bookkeeping inbox, and don’t want to forward each one by hand.

Before you start: an Odoo connection named odoo (see Connect Odoo), a Microsoft 365 connection named m365 that may send from one shared mailbox (see Connect Microsoft 365), and the company variables invoice_mailbox and accountant_email.

Every hour, the workflow:

  1. Lists the confirmed customer invoices and credit notes that changed in Odoo since the last run.
  2. Leaves out the ones it has already sent.
  3. Reads the PDF that Odoo stored for each invoice, at most 50 a run. New invoices go first, but 10 of the 50 places are kept for invoices still waiting from earlier runs, so those get their turn even on busy days.
  4. Emails each PDF to accountant_email from the shared mailbox invoice_mailbox, one email per invoice, with the invoice number in the subject.
  5. Remembers where it stopped, which invoices it sent and which still wait for a PDF.
  6. Emails the shared mailbox a list of the invoices it stopped trying, if there are any, so a person can send them.

No invoice is skipped, and each one is normally sent once. The workflow keeps the ids of the last 2000 invoices it sent and never sends those again, also when Odoo lists an invoice as changed later, for example when it is paid. Runs wait for each other, so two runs can’t both send the same invoice. In rare cases your accountant can get an invoice twice: when Microsoft 365 accepted the email but its answer never reached Liitora, the workflow can’t tell it was sent and sends it again on the next run.

Odoo must have made the PDF first. Odoo stores an invoice’s PDF when someone sends the invoice or generates its PDF in Odoo. An invoice without a stored PDF yet waits, and later runs check it again until the PDF is there, at most 72 times (about three days of hourly runs). After that the workflow stops trying it and lists it in an email to the shared mailbox. Odoo has no documented way to make the PDF from outside, so this workflow never makes one.

When something fails, the invoice waits. If the bot user may not read a PDF or the mailbox refuses an email, that invoice is tried again on the next run and the others still go out. After 3 failed reads, or after the mailbox refused its email 3 times, the workflow stops trying it and lists it in an email to the shared mailbox, with what went wrong. Each kind of problem is counted on its own, so checks while the PDF was missing don’t count as failures. That covers invoices that can never be sent this way, for example one that is no longer confirmed or a PDF larger than about 7 MB. If one of these invoices changes in Odoo later, for example when it is sent again, the workflow tries it again. If Odoo can’t list the changed invoices, the run fails and the next run starts from the same place.

Nothing is left out silently. Up to 500 invoices can wait at a time. If more are waiting, the ones that don’t fit are listed in the email to the shared mailbox instead.

  • odoo: a connection made from the Odoo template. It uses only the ready-made read actions library/odoo.find-changed-invoices@v1 and library/odoo.get-invoice-pdf@v1. It changes nothing in Odoo. The bot user needs the Invoicing or Accounting app and nothing else.
  • m365: a Microsoft 365 connection. It uses only library/ms365.send-mail@v1, from the shared mailbox you name. Limit Mail.Send to that mailbox.
  • It emails only accountant_email and the shared mailbox invoice_mailbox. Each email to the accountant carries one invoice PDF, which shows the customer’s name and address. The email to the shared mailbox names only invoice numbers and why they were not sent.
  • The PDFs are files of the run and are deleted with it after your plan’s retention. Their content is never in a step’s output or the run log.
  • No secret value is ever in the workflow.
  1. Create the Odoo connection from its template and name it odoo. Give its bot user access to the Invoicing or Accounting app (see Connect Odoo).
  2. Create the Microsoft 365 connection, name it m365, give it Mail.Send and limit that to the shared mailbox (see Connect Microsoft 365).
  3. Add the company variables invoice_mailbox (the shared mailbox) and accountant_email (see Use company variables).
  4. Make sure your team sends or generates each invoice in Odoo, so Odoo stores its PDF.
  5. Take it into use from the Liitora library (see Take a library workflow into use), read the test cases on your copy, run them, start a dry run first, and approve it.

The first run starts a day back, so it doesn’t send older invoices.

  • Upload to a folder instead of email. Replace the send step with platform/files.upload@v1 and a file connection (SFTP or S3), with path: invoices/${{ each.item.file.name }}, artifact: ${{ each.item.file }} and overwrite: skip. In the next step, count an item as sent when its output is there.
  • Invoices only, no credit notes. Set include_credit_notes: false in the changed step.
  • Run less often. Change the schedule, for example to once a day.
  • A different email text. Change the send step’s subject and body.

Every hour at 15 minutes past or when someone starts it by hand: read where the last run stopped, then work out where to start, then find confirmed invoices changed since the last run, then pick the invoices to send, then get each invoice’s PDF for each item (even if that fails, the run goes on), then sort out which PDFs to send and which to try again, then email each PDF to the accountant for each item (even if that fails, the run goes on), then work out what to remember, then remember where this run stopped and what it sent. Depending on the result of “Work out what to remember”, email the shared mailbox about invoices it stopped trying.

What Details
Publisher Liitora
Version 1.0.0
Licence Apache-2.0
Content hash sha256:a2c5b53d23cd05c7815cd8ada3ff9cb661b981d93b74865b9970da6a83c11861
Tests 15
Connections m365, odoo
Company variables accountant_email, invoice_mailbox
Secrets None
Personal data Each invoice’s PDF, which shows the customer’s name and address, emailed to the accountant. The workflow keeps only invoice ids and numbers between runs.
Saved state Yes
Runs on your own runner No
Actions library/ms365.send-mail@v1, library/odoo.find-changed-invoices@v1, library/odoo.get-invoice-pdf@v1, platform/state.get@v1, platform/state.set@v1, platform/transform@v1

Liitora signs each version of this workflow. When your company takes it into use, Liitora checks the content hash and the signature again before it copies the workflow into your company. See How the library is kept safe.

# A Liitora library workflow (see the guide, Library > New Odoo invoice PDFs to your accountant).
# Connections used: odoo (from the Odoo template), m365 (Microsoft 365, Mail.Send
# for one shared mailbox). Company variables used: invoice_mailbox,
# accountant_email. Saved state: where the last run stopped, the invoices
# still waiting (id, number and a count per kind of problem) and the last
# 2000 invoices sent, so an invoice is never skipped and in normal runs sent
# once. If Microsoft 365 accepts an email but its answer is lost, that
# invoice is sent again on the next run.
name: New Odoo invoice PDFs to your accountant
description: Every hour, find the customer invoices and credit notes confirmed or changed in Odoo since the last run, read the PDF Odoo stored for each one and email it to the accountant from a shared mailbox, one email per invoice. Invoices without a PDF yet are tried again on the next runs, new invoices first, with room kept for waiting ones. An invoice it gives up on is listed in an email to the shared mailbox.
on:
schedule:
- cron: "15 * * * *"
timezone: Europe/Helsinki
manual: true
# One run at a time, so two runs can't both send the same invoice.
concurrency:
group: odoo-invoice-pdfs
cancel_in_progress: false
steps:
- id: saved
name: Read where the last run stopped
uses: platform/state.get@v1
with:
key: invoice_pdf_export
default: null
- id: start
name: Work out where to start
needs: [saved]
uses: platform/transform@v1
with:
input:
saved: ${{ steps.saved.outputs.value }}
script: |
const s = input.saved !== null && typeof input.saved === "object" ? input.saved : {};
const isId = (x) => typeof x === "number" && Number.isInteger(x) && x > 0;
const ids = (v) => (Array.isArray(v) ? v.filter(isId) : []);
const count = (x) => (typeof x === "number" && Number.isInteger(x) && x >= 0 ? x : 0);
// A waiting invoice: its id, its number when known, and a separate
// count for each kind of problem, so each limit counts only its own.
const entry = (w) =>
w !== null && typeof w === "object" && isId(w.id)
? {
id: w.id,
number: typeof w.number === "string" ? w.number.slice(0, 100) : null,
no_pdf: count(w.no_pdf),
read_failed: count(w.read_failed),
mail_refused: count(w.mail_refused),
}
: null;
const waiting = (Array.isArray(s.waiting) ? s.waiting : []).map(entry).filter((w) => w !== null);
// The first run starts a day back, so it doesn't send old invoices.
const since = typeof s.since === "string" && s.since.length > 0 ? s.since : new Date(Date.now() - 86400000).toISOString().slice(0, 19) + "Z";
return { since: since, waiting: waiting.slice(0, 500), sent: ids(s.sent).slice(0, 2000) };
- id: changed
name: Find confirmed invoices changed since the last run
needs: [start]
uses: library/odoo.find-changed-invoices@v1
connections:
odoo: odoo
with:
since: ${{ steps.start.outputs.result.since }}
only_posted: true
include_credit_notes: true
max_items: 200
retry:
attempts: 3
backoff: exponential
on: [429, 5xx, timeout, network]
- id: pick
name: Pick the invoices to send
needs: [changed]
uses: platform/transform@v1
with:
input:
start: ${{ steps.start.outputs.result }}
invoices: ${{ steps.changed.outputs.invoices }}
script: |
const sent = input.start.sent;
const waiting = input.start.waiting.filter((w) => sent.indexOf(w.id) < 0);
const queued = waiting.map((w) => w.id);
// New invoices first, so invoices that keep waiting never hold them
// up. An invoice already waiting keeps its place and its count.
const fresh = [];
(Array.isArray(input.invoices) ? input.invoices : []).forEach((inv) => {
const id = inv && inv.id;
if (typeof id !== "number" || sent.indexOf(id) >= 0 || queued.indexOf(id) >= 0) return;
if (fresh.some((f) => f.id === id)) return;
fresh.push({ id: id, number: typeof inv.name === "string" ? inv.name.slice(0, 100) : null, no_pdf: 0, read_failed: 0, mail_refused: 0 });
});
// At most 50 a run. 10 of them are kept for waiting invoices when
// there are any, so they get their turn even when many new ones
// come every hour. Free places go to the other kind.
const MAX_RUN = 50;
const freshNow = fresh.slice(0, MAX_RUN - Math.min(10, waiting.length));
const waitNow = waiting.slice(0, MAX_RUN - freshNow.length);
return {
now: freshNow.concat(waitNow),
later: fresh.slice(freshNow.length).concat(waiting.slice(waitNow.length)),
};
- id: pdf
name: Get each invoice's PDF
needs: [pick]
uses: library/odoo.get-invoice-pdf@v1
connections:
odoo: odoo
strategy:
for_each: ${{ steps.pick.outputs.result.now }}
max_parallel: 1
fail_fast: false
continue_on_error: true
with:
invoice_id: ${{ each.item.id }}
retry:
attempts: 3
backoff: exponential
on: [429, 5xx, timeout, network]
- id: ready
name: Sort out which PDFs to send and which to try again
needs: [pdf]
uses: platform/transform@v1
with:
input:
asked: ${{ steps.pick.outputs.result.now }}
got: ${{ steps.pdf.outputs }}
script: |
// An invoice without a PDF is checked 72 times (about three days of
// hourly runs). One whose PDF can't be read is tried 3 times: that
// covers a short outage, and a lasting problem (the invoice is no
// longer confirmed, the PDF is too large, a missing access right)
// needs a person anyway.
const MAX_NO_PDF = 72;
const MAX_FAILED = 3;
const got = Array.isArray(input.got) ? input.got : [];
const send = [];
const retry = [];
const gaveUp = [];
input.asked.forEach((item, i) => {
const r = got[i];
const number = r && typeof r.invoice_number === "string" ? r.invoice_number.slice(0, 100) : item.number;
const w = Object.assign({}, item, { number: number });
if (r && r.status === "found" && r.file) {
send.push(Object.assign({}, w, { label: number || "invoice " + item.id, file: r.file }));
return;
}
const noPdf = r && r.status === "no_pdf_yet";
if (noPdf) w.no_pdf += 1;
else w.read_failed += 1;
if (noPdf ? w.no_pdf >= MAX_NO_PDF : w.read_failed >= MAX_FAILED) {
gaveUp.push({ id: item.id, number: number, why: noPdf ? "no_pdf" : "failed" });
} else {
// Tried again on a later run.
retry.push(w);
}
});
return { send: send, retry: retry, gave_up: gaveUp };
- id: send
name: Email each PDF to the accountant
needs: [ready]
uses: library/ms365.send-mail@v1
connections:
graph: m365
strategy:
for_each: ${{ steps.ready.outputs.result.send }}
max_parallel: 1
fail_fast: false
continue_on_error: true
with:
mailbox: ${{ vars.invoice_mailbox }}
to: ["${{ vars.accountant_email }}"]
subject: "Invoice ${{ each.item.label }}"
body: "Attached is ${{ each.item.label }} from Odoo, sent by Liitora."
attachments: ["${{ each.item.file }}"]
- id: next
name: Work out what to remember
needs: [send]
uses: platform/transform@v1
with:
input:
start: ${{ steps.start.outputs.result }}
pick: ${{ steps.pick.outputs.result }}
ready: ${{ steps.ready.outputs.result }}
sent: ${{ steps.send.outputs }}
next_since: ${{ steps.changed.outputs.next_since }}
script: |
const MAX_FAILED = 3;
const MAX_WAITING = 500;
const results = Array.isArray(input.sent) ? input.sent : [];
const done = [];
const failed = [];
const gaveUp = input.ready.gave_up.slice();
input.ready.send.forEach((item, i) => {
const r = results[i];
if (r && r.accepted === true) {
done.push(item.id);
return;
}
const w = { id: item.id, number: item.number, no_pdf: item.no_pdf, read_failed: item.read_failed, mail_refused: item.mail_refused + 1 };
if (w.mail_refused >= MAX_FAILED) gaveUp.push({ id: item.id, number: item.number, why: "mail" });
else failed.push(w);
});
// The ones not tried this run keep their place; the ones tried
// again go to the back, so every waiting invoice gets its turn.
const queue = input.pick.later.concat(input.ready.retry, failed);
// A full list never drops an invoice silently: it is in the email.
queue.slice(MAX_WAITING).forEach((w) => gaveUp.push({ id: w.id, number: w.number, why: "full" }));
const reasons = {
no_pdf: "Odoo still has no PDF for it after 72 checks. Send or generate the invoice in Odoo, then email its PDF to your accountant yourself.",
failed: "Reading its PDF from Odoo failed 3 times, for example because the invoice is no longer confirmed, its PDF is larger than about 7 MB, or the bot user may not read it. Check the invoice in Odoo and email its PDF yourself.",
mail: "The mailbox refused the email 3 times. Email its PDF yourself.",
full: "More than " + MAX_WAITING + " invoices were waiting, so this one was left out. Email its PDF yourself.",
};
const lines = gaveUp.map((g) => "- " + (g.number || "The invoice with the id " + g.id) + ": " + reasons[g.why]);
const alert =
lines.length === 0
? ""
: "Liitora stopped trying to email these Odoo invoices to your accountant:\n\n" +
lines.join("\n") +
"\n\nIf one of them changes in Odoo later, for example when it is sent again, the workflow tries it again.";
return {
state: {
since: typeof input.next_since === "string" && input.next_since.length > 0 ? input.next_since : input.start.since,
waiting: queue.slice(0, MAX_WAITING),
sent: done.concat(input.start.sent).slice(0, 2000),
},
sent: done.length,
waiting: Math.min(queue.length, MAX_WAITING),
failed: failed.length,
gave_up: gaveUp.length,
alert: alert,
};
- id: remember
name: Remember where this run stopped and what it sent
needs: [next]
uses: platform/state.set@v1
with:
key: invoice_pdf_export
value: ${{ steps.next.outputs.result.state }}
- id: alert
name: Email the shared mailbox about invoices it stopped trying
needs: [remember]
if: ${{ steps.next.outputs.result.gave_up > 0 }}
uses: library/ms365.send-mail@v1
connections:
graph: m365
with:
mailbox: ${{ vars.invoice_mailbox }}
to: ["${{ vars.invoice_mailbox }}"]
subject: "Invoices not sent to your accountant"
body: ${{ steps.next.outputs.result.alert }}
  • 1.0.0 (2026-11-17): First version in the library.