Create Odoo customers and sales orders from paid Shopify orders

By General Input

When a Shopify order is paid, we match or create the customer in Odoo, build the sales order with mapped products, and post a Slack recap to your ops channel.

Integrations

  • Odoo
  • Shopify
  • Slack

Type

Deterministic Code

Categories

  • Operations
  • Sales

When a Shopify order is paid, create the matching customer and sales order in my Odoo instance automatically so my storefront and my ERP stay in step.

Trigger this on a Shopify webhook for the order paid event (orders/paid). When the webhook fires, take the order id from the payload and use the Shopify Get Order operation to pull the full order, including line items, customer details, currency and totals. Work from that fetched order rather than trusting the webhook body, so the data is always complete.

Before writing anything, check for a redelivery. Shopify retries webhook deliveries, so use Search & Read Records (search_read) on sale.order in Odoo with a domain matching client_order_ref against the Shopify order id. If a sales order already exists, update that order instead of creating a new one, and end the run with a Slack message that says it was an update rather than a new order. Never create a second sales order for the same Shopify order id.

Resolve the customer next. Use Name Search (name_search) on res.partner to find an existing contact by the order's email, and fall back to the customer name if the email finds nothing. If there is no match, use Create Record (create) on res.partner to add the customer with their name, email, phone and billing address. Reuse the existing contact whenever one is found so regular buyers do not get duplicated.

Then resolve products. For each Shopify line item, use Name Search (name_search) on product.product to find the matching Odoo product, searching on the SKU first and then the product title. Keep a list of any line items that come back with no match, or with an ambiguous match of more than one product, and treat those as unmatched.

Create the sales order with Create Record (create) on sale.order. Set partner_id to the resolved customer, set client_order_ref to the Shopify order id or order name so future redeliveries can find it, and build order_line from the matched line items using Odoo's relational create commands, one line per item with the product id, quantity and unit price taken from Shopify. Include shipping and discounts as their own lines where the Shopify order has them, so the Odoo total reconciles against the Shopify total.

If every line item matched a product, use Call Model Method (execute_kw) to confirm the sales order (action_confirm) so fulfillment and invoicing pick it up. If any SKU failed to match, do not confirm: leave the sales order in draft with the matched lines on it, and leave the unmatched items off the order so nobody accidentally ships the wrong thing.

Finally, post to my ops channel in Slack with Send a Message. Include the Shopify order number, the customer name, the order total with currency, a link to the Odoo sales order, and whether the order was confirmed or left in draft. If there were unmatched line items, call them out clearly at the top of the message with the SKU, product title and quantity for each one, so someone can add the missing product in Odoo and confirm the order by hand. Never silently drop a line item.

If Odoo rejects a call or is unreachable, do not swallow the error: post a Slack message naming the Shopify order number and the reason it failed, so the order can be replayed or entered manually.

Related prompts

Explore more prompts
Call overdue Xero customers with an AI collections agentWin back LiveChat visitors whose chats went unansweredChat quality review board for LiveChat support leadsReceiving dock console for inspecting and restocking Loop returnsWin back no-show and cancelled appointments every morningSee which influencer creators actually drove Shopify salesLive Loop returns analytics with product-level drill-downNewsletter pre-flight and approval board for Mailjet sendsTurn a prospect spreadsheet into personalized sequence enrollmentsMailjet email delivery lookup console for support teams