# Odoo Manufacturing API: Working with mrp.production and mrp.bom

> Source: https://netray.co/erp-help/odoo-manufacturing-api-mrp-production-bom-xmlrpc-jsonrpc
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: ERP Help

## Short answer

Odoo exposes manufacturing through its normal external API: the models mrp.bom (bills of materials), mrp.production (manufacturing orders) and mrp.workorder, called via XML-RPC or JSON-RPC with execute_kw. Authenticate, search and read the BOM, create a manufacturing order, then call its action methods such as action_confirm to move it through states. There is no separate manufacturing API.

## Kind

how-to

## System

small-erp

## Erp

Odoo (Manufacturing / MRP)

## Module

Manufacturing / External API

## Query

odoo manufacturing api

## Alternate Queries

- odoo mrp.production api
- odoo create manufacturing order xmlrpc
- odoo bom api

## Applies To

Odoo Manufacturing (MRP) in recent versions, Community and Enterprise. Field names and behaviour change between versions, so check your model definitions through the Technical menu or fields_get.

## Steps

### Create and confirm a manufacturing order over the API

**Items:**

- Authenticate to the common endpoint with database, login and password or API key, and keep the returned user id.
- Look up the product with search_read on product.product, and read the BOM with search_read on mrp.bom filtered by product_tmpl_id.
- Read the BOM lines from mrp.bom.line using the BOM id, to see components and quantities.
- Create the manufacturing order with create on mrp.production, giving product_id, product_qty, product_uom_id and bom_id.
- Call action_confirm on the new order to confirm it, which creates the stock moves for components and finished product.
- Check availability and state by reading state, reservation_state and move_raw_ids.
- To finish, set the produced quantity and call button_mark_done. Be ready for it to return a wizard action instead of finishing, if confirmation is needed.

## Sections

### A worked example in Python

**Body:**

This uses the standard xmlrpc.client library. Replace the connection values with your own. Test on a copy of the database, since creating and confirming orders reserves stock.

**Code:**

import xmlrpc.client
url, db, user, key = 'https://odoo.example.com', 'mydb', 'api@example.com', 'API_KEY'
common = xmlrpc.client.ServerProxy(url + '/xmlrpc/2/common')
uid = common.authenticate(db, user, key, {})
m = xmlrpc.client.ServerProxy(url + '/xmlrpc/2/object')

def call(model, method, *args, **kw):
    return m.execute_kw(db, uid, key, model, method, list(args), kw)

prod = call('product.product', 'search_read', [['default_code', '=', 'FG-100']], fields=['id', 'uom_id'], limit=1)[0]
bom = call('mrp.bom', 'search_read', [['product_tmpl_id.default_code', '=', 'FG-100']], fields=['id'], limit=1)[0]
mo_id = call('mrp.production', 'create', [{'product_id': prod['id'], 'product_qty': 10, 'product_uom_id': prod['uom_id'][0], 'bom_id': bom['id']}])
call('mrp.production', 'action_confirm', [mo_id])
print(call('mrp.production', 'read', [mo_id], fields=['name', 'state', 'reservation_state']))

### States and methods to know

**Body:**

A manufacturing order moves through draft, confirmed, in progress, to do, done and cancel states, although labels vary by version. The action methods are what the buttons on the form call, for example action_confirm, button_plan for work orders, button_mark_done, and action_cancel.

Some of those methods return a dictionary describing a wizard, for example a warning about consumption or an immediate production prompt. An integration must check the return value, and either handle the wizard model or set quantities first so the wizard is not needed.

### Practical advice for integrations

**Body:**

Use fields_get on mrp.production to see what fields your version supports, and read only the fields you need. Avoid reading every field on large orders.

For many records, batch calls rather than one request per record. Use an API key for a dedicated integration user with only manufacturing rights, so you can revoke it without affecting people.

Odoo's external API is documented by Odoo, and JSON-RPC and XML-RPC are both supported. Check which one your version recommends, since newer releases have been evolving the external API.

## Pitfalls

- Writing stock moves directly instead of using the order methods.
- Ignoring the wizard dictionary returned by button_mark_done.
- Using an admin account for the integration.
- Testing on production, so reservations pile up.
- Assuming field names are the same across versions.
- Creating orders without a BOM and wondering why components are missing.

## Ai Angle

Read access to mrp.production and mrp.bom is a good fit for a grounded assistant that answers which manufacturing orders are late or blocked on components. Writes such as confirming an order should go through a human approval step. Hosting the model on-prem keeps BOMs and production data inside your network.

## Faq

### Does Odoo have a manufacturing API?

**Answer:** It uses the general external API (XML-RPC and JSON-RPC) with manufacturing models such as mrp.production and mrp.bom, rather than a separate API.

### How do I create a manufacturing order via API?

**Answer:** Call create on mrp.production with product, quantity, unit of measure and BOM, then call action_confirm.

### How do I read a BOM?

**Answer:** Search mrp.bom for the product, then read mrp.bom.line records for the BOM id to get components and quantities.

### Why does button_mark_done not finish the order?

**Answer:** It may return a wizard action, such as an immediate production or consumption warning. Handle that wizard or set quantities first.

## Search terms

odoo manufacturing api, odoo mrp.production api, odoo create manufacturing order xmlrpc, odoo bom api, odoo external api manufacturing, odoo mrp xmlrpc, odoo action_confirm manufacturing order

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
