Technical

WooCommerce Odoo Integration: Sync Rules, Stock, Orders, Taxes

A practical guide to connecting WooCommerce and Odoo through the WooCommerce REST API: what to sync in which direction, how to push stock and prices, import orders safely, map taxes and avoid duplicate customers and orders.

Kalvyai Engineering · · 8 min read

WooCommerce Odoo Integration: Sync Rules, Stock, Orders, Taxes (cover)
On this page

Most WooCommerce and Odoo integrations fail in the same few places. Stock drifts. Orders import twice. One customer becomes five partners. Tax totals are off by a cent. None of these problems come from the API itself. They come from sync rules that were never written down.

This post covers the decisions and the mechanics: which system owns which data, how the WooCommerce REST API works for this job, and the specific checks that keep duplicates out of Odoo.

Decide the source of truth before writing code

Every field should have one owner. If both systems can edit stock or price, you will eventually overwrite a correct value with a stale one.

A sensible default for most shops:

Data

Owner

Direction

Product master (SKU, cost, variants)

Odoo

Odoo → WooCommerce

Marketing content (descriptions, images, SEO)

WooCommerce

Stays in WooCommerce

Stock quantity

Odoo

Odoo → WooCommerce

Price

Odoo

Odoo → WooCommerce

Orders

WooCommerce

WooCommerce → Odoo

Customers and addresses

WooCommerce at checkout

WooCommerce → Odoo

Fulfilment status and tracking

Odoo

Odoo → WooCommerce

Refunds

Depends on your process

Pick one side and document it

Some shops reverse the product direction because their catalogue team works in WordPress. That is fine, as long as it is a deliberate choice and the other side treats those fields as read-only.

WooCommerce REST API basics

The current API lives under /wp-json/wc/v3/. The endpoints you will use most:

  • /products and /products/{id}/variations
  • /products/batch and /products/{id}/variations/batch
  • /orders and /orders/{id}
  • /customers
  • /taxes
  • /webhooks

Authentication

Generate a consumer key and secret in WooCommerce under WooCommerce → Settings → Advanced → REST API. Give the key read/write access only if the integration needs to write. Over HTTPS you can send the key and secret as HTTP Basic credentials.

Store the secret in Odoo in a field restricted to administrators, not in a plain system parameter that every internal user can read.

Pagination

List endpoints return at most 100 records per page (per_page=100). The response headers X-WP-Total and X-WP-TotalPages tell you how many pages remain. Always loop until you run out of pages; never assume one call returns everything.

Python
import requests

BASE = "https://shop.example.com/wp-json/wc/v3"
AUTH = ("ck_xxx", "cs_xxx")

def fetch_orders(modified_after: str):
    page = 1
    while True:
        resp = requests.get(
            f"{BASE}/orders",
            auth=AUTH,
            params={
                "modified_after": modified_after,  # ISO 8601
                "per_page": 100,
                "page": page,
            },
            timeout=30,
        )
        resp.raise_for_status()
        yield from resp.json()
        if page >= int(resp.headers.get("X-WP-TotalPages", 1)):
            break
        page += 1

Check that modified_after is supported on the WooCommerce version in use; older versions only support after based on creation date.

Webhooks

Webhooks push events such as order.created, order.updated and product.updated to a URL you control. Each delivery carries an X-WC-Webhook-Signature header: a base64-encoded HMAC-SHA256 of the raw body, using the webhook secret. Verify it before doing anything with the payload.

Python
import base64
import hashlib
import hmac

def verify_woo_signature(raw_body: bytes, header_sig: str, secret: str) -> bool:
    digest = hmac.new(secret.encode(), raw_body, hashlib.sha256).digest()
    expected = base64.b64encode(digest).decode()
    return hmac.compare_digest(expected, header_sig or "")

Webhooks are fast but not guaranteed. WordPress can disable a webhook after repeated failed deliveries, and a server outage on either side means missed events. Use webhooks for speed and a scheduled poll for completeness. More on that in the order section.

Product mapping: use SKU, then store the IDs

Match products on SKU the first time, then save the WooCommerce product ID (and variation ID) on the Odoo product.product record. After the first match, sync by ID, not by SKU. SKUs get edited; IDs do not.

Rules that save trouble:

  1. Every sellable variant needs a unique, non-empty SKU on both sides before go-live.
  2. A WooCommerce variable product maps to an Odoo product template; each WooCommerce variation maps to an Odoo variant.
  3. Simple products map to a template with a single variant.
  4. If you run more than one store, the mapping key is (store, WooCommerce ID), not just the ID. Two stores can both have a product with ID 812.

Stock updates: Odoo to WooCommerce

Which quantity to send

Do not send on-hand quantity. Send what is actually free to sell: on hand minus what is already reserved for other orders. In Odoo that is the free_qty field on the product, and you can compute it for a specific warehouse or location by passing it in the context.

Many shops also subtract a safety buffer (for example, two units) so that a slow sync never sells the last physical item twice.

How to send it

Push changes, not the whole catalogue. Trigger on stock moves, collect changed products in a queue, and flush every few minutes with batch calls.

HTTP
POST /wp-json/wc/v3/products/batch
Content-Type: application/json
JSON
{
  "update": [
    { "id": 812, "manage_stock": true, "stock_quantity": 14 },
    { "id": 813, "manage_stock": true, "stock_quantity": 0 }
  ]
}

Variations go through /products/{product_id}/variations/batch with the same body shape. Batch endpoints accept up to 100 items per request by default, so chunk larger updates.

Run a full stock reconciliation once a night as well. It catches anything a missed event or a manual edit in WooCommerce left behind.

Price updates

WooCommerce stores regular_price and sale_price as strings. Send them already rounded to the shop's currency precision.

Decide upfront:

  • Which Odoo price feeds WooCommerce. The product sales price, or a specific pricelist for the web channel. A dedicated pricelist is cleaner if web prices differ from counter or B2B prices.
  • Tax-inclusive or exclusive. The price you push must match how WooCommerce is configured to enter prices (the "prices entered with tax" setting). If WooCommerce expects tax-inclusive prices and you push net prices, every order will be under-priced.
  • Who owns sale prices. If marketing runs promotions in WooCommerce, do not let the sync clear sale_price on every run. Only send the fields Odoo owns.

Order import: WooCommerce to Odoo

Two channels, one import function

  1. A webhook on order.created and order.updated enqueues the WooCommerce order ID.
  2. A scheduled job polls /orders with a modified-after timestamp (minus a few minutes of overlap) and enqueues the same IDs.
  3. One worker processes the queue. It fetches the full order from the API by ID, so it always works from current data rather than a possibly stale webhook payload.

Because both channels feed the same function, that function must be idempotent. See the duplicates section below.

Map statuses explicitly

WooCommerce order statuses include pending, on-hold, processing, completed, cancelled, refunded and failed. Write a mapping table rather than scattering if statements:

WooCommerce status

Action in Odoo

pending, failed

Do not import, or import as a quotation only

on-hold

Import as quotation (for example, awaiting bank transfer)

processing

Confirm the sales order, register payment if paid online

cancelled

Cancel the order if nothing has shipped; otherwise flag for review

refunded

Flag for review and create a credit note through your normal process

In the other direction, when the Odoo delivery is validated, set the WooCommerce order to completed. If you share tracking numbers, how you write them depends on the shipment tracking plugin the shop uses.

Lines to handle besides products

A WooCommerce order has more than line_items:

  • shipping_lines: map to a delivery product in Odoo, with its tax.
  • fee_lines: map to a service product (payment surcharges, gift wrap).
  • coupon_lines: the discount is already reflected in each line item, where subtotal is before discount and total is after. Import the discounted amounts, and optionally keep the coupon code on the order for reporting.

Taxes

Tax is where totals drift. WooCommerce calculates tax at checkout; Odoo will recalculate it from its own tax records. If the two disagree, your invoice will not match what the customer paid.

  1. Map tax rates, not names. Each WooCommerce tax rate has an ID. Map each ID to an Odoo account.tax record in a configuration table. Fail the import loudly when an unmapped rate appears.
  2. Match the inclusive/exclusive setting. The order payload has prices_include_tax. The mapped Odoo tax should have the same price-included behaviour, or you need separate tax records for each case.
  3. Use fiscal positions for cross-border sales if your Odoo setup relies on them, but make sure the result lands on the same rate WooCommerce charged.
  4. Compare totals after import. Once the Odoo order is built, compare its total with the WooCommerce total. If the difference is above a small tolerance, put the order in an exception queue for a person to check. Do not silently add an adjustment line without a review step.
  5. Rounding. Per-line versus global rounding can produce one-cent differences. Align Odoo's tax rounding method with how WooCommerce rounds.

Avoiding duplicate customers

Customer duplicates usually come from guest checkouts and from treating every address as a new contact.

  1. Registered customers: store the WooCommerce customer_id on the Odoo partner, per store. Match on that first.
  2. Guest orders have customer_id of 0. Match on the billing email, normalised: trimmed and lowercased.
  3. When a guest later registers, the email match links the new WooCommerce customer ID to the existing partner instead of creating a new one.
  4. Addresses: create invoice and delivery addresses as child contacts of the main partner. Before creating one, compare it with existing child contacts (normalised street, postcode, country). Reuse a match; create only when it is genuinely new.
  5. No email at all (rare, but some phone-order plugins allow it): send the order to a review queue rather than guessing.

Do not match on name alone. Two different people called the same thing is common enough to cause real problems with invoices.

Avoiding duplicate orders

Webhook retries, a poll overlapping a webhook, or two workers picking up the same job can all create the same order twice. Defend in layers.

1. Store the external ID on the order

Python
from odoo import fields, models

class SaleOrder(models.Model):
    _inherit = "sale.order"

    woo_store_id = fields.Many2one("woo.store", index=True)
    woo_order_id = fields.Char(index=True, copy=False)

    _sql_constraints = [
        (
            "woo_order_unique",
            "unique(woo_store_id, woo_order_id)",
            "This WooCommerce order is already imported.",
        ),
    ]

In Odoo 19 and later, _sql_constraints is deprecated: declare the same rule with models.Constraint instead.

Set copy=False so duplicating an order in Odoo does not copy the WooCommerce ID and break the constraint.

2. Look up before you create

The import function searches for an existing order with the same store and WooCommerce ID. If found, it updates status where allowed. If not, it creates.

3. Let the database be the final guard

The unique constraint catches the race where two workers both search, find nothing, and both try to create. One succeeds; the other gets an integrity error, which the worker should treat as "already imported" and move on, not as a failure to retry forever.

4. Serialise per order

If your queue supports it, give each job a key based on the store and order ID so two jobs for the same order never run at once. This removes most races before they reach the database.

A go-live checklist

  1. Every sellable variant has a unique SKU on both sides.
  2. Every WooCommerce tax rate is mapped to an Odoo tax.
  3. Price entry mode (inclusive/exclusive) matches on both sides.
  4. Webhooks are created, signatures verified, and the poll job is running.
  5. Import the last 30 days of orders into a test database and compare totals.
  6. Place test orders: guest, registered, coupon, multiple tax rates, cancelled, refunded.
  7. Re-send the same webhook twice and confirm only one order exists.
  8. Check the exception queue is visible to someone who will act on it.

How Kalvyai can help

We build and maintain Odoo integrations, including WooCommerce connections with custom sync rules, tax mapping and exception handling for single and multi-store setups.

If you would rather start from a ready app, our WooCommerce Connector provides bi-directional sync between Odoo and one or more WooCommerce stores, with Power BI insights. For shops running several channels, ConnectIQ adds unified sync telemetry, queue tracking and AI error diagnostics so failed syncs are visible instead of silent. All our apps are at store.kalvyai.com.

To talk through your setup, contact us.

Share this article

  • WooCommerce
  • Odoo
  • Integration
  • REST API
  • Inventory Sync
  • Order Import
  • ERP

Kalvyai Engineering · Engineering team

The engineers who build, connect and fix business systems at Kalvyai: Odoo, ERPNext, Shopify and AI agents that work inside them with approvals, budgets and an audit trail.

Comments

No comments yet. Questions and corrections are welcome.

Rate this post or leave a comment

Your rating (optional)
Not rated

Comments appear after an editor approves them. See our privacy notice.

Read next

Tally to Odoo Migration: What to Move, Map and Check (cover)Technical
Kalvyai EngineeringOdoo

Tally to Odoo Migration: What to Move, Map and Check

A practical guide to moving from Tally to Odoo: which masters, balances, open invoices and stock to bring, what to leave in Tally, how to map ledgers and set up GST, and how to run a parallel month.

7 min read

Odoo Community vs Enterprise: Features, Hosting and How to Choose (cover)Technical
Kalvyai EngineeringOdoo

Odoo Community vs Enterprise: Features, Hosting and How to Choose

A practical comparison of Odoo Community and Enterprise: which features are Enterprise-only, what OCA and third-party apps cover, where each edition can be hosted, how upgrades work, and a step-by-step way to decide.

8 min read

Newsletter

Get new guides in your inbox.

Practical notes on Odoo, ERPNext, Shopify and AI agents, written by the engineers who build them. No spam, and you can ask to stop at any time.

Prefer a feed? Subscribe by RSS. We use your email only to send new articles. See our privacy policy.