Webshop order becomes a confirmed Odoo sales order
Who this is for: sales and order handling teams who sell in a webshop or take orders through a web form, run sales in Odoo, and don’t want to type every order in again.
Before you start: an Odoo connection named odoo (see Connect Odoo), the company variable sales_owner, and a webshop or form tool that can send a webhook when an order is placed.
What it does
Section titled “What it does”Your webshop or form tool calls a webhook for each order, with the shop’s order number, the customer and the order lines. The workflow:
- Checks the order and refuses anything it doesn’t understand, before it calls Odoo.
- Finds the customer in Odoo by email address and updates them with what the shop sent, or creates them. Fields the shop left out are never emptied in Odoo.
- Creates a quotation for the customer, with the shop’s order number as the order’s Customer Reference. Products are matched by their Internal Reference in Odoo, and every product is checked before anything is written.
- Confirms the quotation, so it becomes a sales order.
Each shop order is created once. The order step first looks for an order with the same Customer Reference and returns it when it is there, and the confirm step leaves an order that is already confirmed alone. When the shop sends the same order again, for example after a timeout on its side, nothing new is created. Runs for shop orders wait for each other, so two deliveries at the same moment can’t both create one.
When a product or a price doesn’t match, nothing is created and the sales owner gets an email:
- Unknown product. A product code the shop sends that no product in Odoo has as its Internal Reference, or a product that can’t be sold.
- A different price. A shop price more than a cent away from the product’s Sales Price in Odoo. The workflow can’t tell which one is right, so a person decides. The check uses the Sales Price only, not price lists or discount rules in Odoo.
A cancelled shop order (status cancelled) is not created, and the sales owner is asked to cancel any order already in Odoo by hand. The workflow never cancels anything in Odoo itself.
What it can access
Section titled “What it can access”odoo: a connection made from the Odoo template. It uses only the ready-made actionslibrary/odoo.upsert-customer@v1,library/odoo.create-sales-order@v1andlibrary/odoo.confirm-sales-order@v1. The bot user needs Sales with all documents and the Contacts right to create contacts, and nothing else.- It writes the customer’s name and email address to Odoo, and their phone number, address and VAT number when the shop sends them.
- It emails only
sales_owner, and only about a cancelled order or one it couldn’t create. The email names the shop order number, not the customer. - No secret value is ever in the workflow.
What you need to set up
Section titled “What you need to set up”- Create the Odoo connection from its template and name it
odoo. Give its bot user Sales with all documents and the Contacts creation right (see Connect Odoo). - Make sure each product the shop sells has the shop’s product code as its Internal Reference in Odoo, or adapt the workflow as described below.
- Add the company variable
sales_owner: who should get the emails (see Use company variables). - Point your shop’s “order placed” event at the workflow’s webhook endpoint,
shop-order(see Set up a webhook), signed, with anIdempotency-Keyheader per event. The body is JSON withorder_number, an optionalstatus(cancelledorcanceledfor a cancelled order),customer(nameandemail, and optionallyphone,street,street2,zip,cityandvat) andlines, each withsku,quantityand optionallyprice. - 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 against a test database first, and approve it.
How to adapt it
Section titled “How to adapt it”- The shop’s prices win. If your shop is where prices are set, change the
orderstep’sprices: checktoprices: shop. - Shop codes that differ from Odoo’s. Keep a lookup table from the shop’s codes to Odoo’s Internal References, and read it in the
checkstep’s script withctx.lookup. - Leave orders as quotations. Remove the
confirmstep, and a person confirms each quotation in Odoo. - Several companies in one Odoo database. Add
company_idto theorderstep. - A different payload. Change the
checkstep’s script, which reads the shop’s order and refuses anything it doesn’t understand.
What Liitora shows on the approval page
Section titled “What Liitora shows on the approval page”When the shop-order webhook is called, check the shop order. Depending on that result, tell the sales owner about a cancelled shop order and create or update the customer in Odoo. Depending on the result of “Create or update the customer in Odoo”, create the quotation in Odoo. If its condition is met, confirm the quotation. If its condition is met, email the sales owner when the order could not be created.
Trust details
Section titled “Trust details”| What | Details |
|---|---|
| Publisher | Liitora |
| Version | 1.0.0 |
| Licence | Apache-2.0 |
| Content hash | sha256:e3bd679d5a27241f2c4181ee81470440aac547780e4fb59d6804b524908a19fc |
| Tests | 8 |
| Connections | odoo |
| Company variables | sales_owner |
| Secrets | None |
| Personal data | The customer’s name, email address and, when the shop sends them, phone number, address and VAT number, written to the customer in Odoo. The sales owner’s emails name only the shop order number. |
| Saved state | No |
| Runs on your own runner | No |
| Actions | library/odoo.confirm-sales-order@v1, library/odoo.create-sales-order@v1, library/odoo.upsert-customer@v1, platform/email.send@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.
The full YAML
Section titled “The full YAML”# A Liitora library workflow (see the guide, Library > Webshop order becomes a confirmed Odoo sales order).# Connection used: odoo (from the Odoo template). Company variable used:# sales_owner. The shop's order number is the key: an order that is already# in Odoo is returned, never created again.name: Webshop order becomes a confirmed Odoo sales orderdescription: When your webshop or a web form sends an order, create or update the customer in Odoo, create the quotation with the shop's order number as its reference, and confirm it. Creates nothing for an unknown product or a price that differs from Odoo's, and emails the sales owner instead. A cancelled shop order is not created, and the sales owner is told.
on: webhook: endpoint: shop-order
# One shop order at a time, so two deliveries of the same order can't both# find no order and create two.concurrency: group: odoo-shop-orders cancel_in_progress: false
steps: - id: check name: Check the shop order uses: platform/transform@v1 with: input: ${{ trigger.body }} script: | const b = input; if (b === null || typeof b !== "object" || Array.isArray(b)) { throw new Error("The shop order must be a JSON object."); } const number = typeof b.order_number === "string" ? b.order_number.trim() : typeof b.order_number === "number" ? String(b.order_number) : ""; if (!/^[A-Za-z0-9._:#\/-]{1,100}$/.test(number)) { throw new Error("order_number must be 1 to 100 letters, digits or . _ : # / -"); } const status = typeof b.status === "string" ? b.status.trim().toLowerCase() : "new"; const c = b.customer; if (c === null || typeof c !== "object" || Array.isArray(c)) { throw new Error("customer must be an object with at least name and email."); } const textOf = (v, max) => (typeof v === "string" && v.trim().length > 0 ? v.trim().slice(0, max) : null); const email = textOf(c.email, 254); const name = textOf(c.name, 200); if (email === null || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email) || email.indexOf("%") >= 0) { throw new Error("customer.email must be an email address."); } if (name === null) { throw new Error("customer.name is needed."); } // Only the fields the shop sent, so a field the shop left out is // never emptied in Odoo. const values = { name: name, email: email }; for (const k of ["phone", "street", "street2", "zip", "city", "vat"]) { const v = textOf(c[k], 200); if (v !== null) values[k] = v; } if (!Array.isArray(b.lines) || b.lines.length === 0 || b.lines.length > 100) { throw new Error("lines must list 1 to 100 order lines."); } const lines = b.lines.map((l, i) => { if (l === null || typeof l !== "object") throw new Error("lines[" + i + "] must be an object."); const sku = textOf(l.sku, 100); if (sku === null) throw new Error("lines[" + i + "].sku is needed."); if (typeof l.quantity !== "number" || !isFinite(l.quantity) || l.quantity <= 0) { throw new Error("lines[" + i + "].quantity must be a number above 0."); } const line = { default_code: sku, quantity: l.quantity }; if (l.price !== undefined && l.price !== null) { if (typeof l.price !== "number" || !isFinite(l.price) || l.price < 0) { throw new Error("lines[" + i + "].price must be a number of at least 0."); } line.price_unit = l.price; } return line; }); return { order_number: number, cancelled: status === "cancelled" || status === "canceled", email: email, values: values, lines: lines };
- id: cancelled name: Tell the sales owner about a cancelled shop order needs: [check] if: ${{ steps.check.outputs.result.cancelled == true }} uses: platform/email.send@v1 with: to: ["${{ vars.sales_owner }}"] subject: "Shop order cancelled: ${{ steps.check.outputs.result.order_number }}" text: "Shop order ${{ steps.check.outputs.result.order_number }} was cancelled in the shop. Liitora did not create or change anything in Odoo for it. If a quotation or sales order with this customer reference is already in Odoo, cancel it there."
- id: customer name: Create or update the customer in Odoo needs: [check] if: ${{ steps.check.outputs.result.cancelled == false }} uses: library/odoo.upsert-customer@v1 connections: odoo: odoo with: email: ${{ steps.check.outputs.result.email }} values: ${{ steps.check.outputs.result.values }} retry: attempts: 3 backoff: exponential on: [429, 503]
- id: order name: Create the quotation in Odoo needs: [customer] if: ${{ steps.customer.outputs.id != null }} uses: library/odoo.create-sales-order@v1 connections: odoo: odoo with: partner_id: ${{ steps.customer.outputs.id }} client_order_ref: ${{ steps.check.outputs.result.order_number }} lines: ${{ steps.check.outputs.result.lines }} prices: check origin: Webshop retry: attempts: 3 backoff: exponential on: [429, 503]
- id: confirm name: Confirm the quotation needs: [order] if: ${{ steps.order.outputs.order != null && steps.order.outputs.order.state != 'cancel' }} uses: library/odoo.confirm-sales-order@v1 connections: odoo: odoo with: order_id: ${{ steps.order.outputs.order_id }} retry: attempts: 3 backoff: exponential on: [429, 503]
- id: alert name: Email the sales owner when the order could not be created needs: [confirm] if: ${{ failure() && steps.check.result == 'success' }} uses: platform/email.send@v1 with: to: ["${{ vars.sales_owner }}"] subject: "Shop order not in Odoo: ${{ steps.check.outputs.result.order_number }}" text: "Shop order ${{ steps.check.outputs.result.order_number }} could not be created or confirmed in Odoo, for example because a product is unknown there or its price differs. Open the run in Liitora to see which step stopped and why, fix it in Odoo or in the shop, and send the order again. The workflow finds an order it already created by its number, so nothing is created twice."Changelog
Section titled “Changelog”- 1.0.0 (2026-11-17): First version in the library.