Read BOM Operations

BOM operations are individual operations that are performed on the item. This means that, despite having the same name as other operations on other BOMs, the items shown are unique.

So even if you see duplicates in Odoo, they each have their own underlying unique operationId for that line in the BOM.

The best way to manage operations is to be consistent in your naming convention for your operations.

In other words, if you are going to assemble something, always give it the exact same name (e.g. Assembly or Assemble).

Choose what to display

The work centers and operations both depend on mpr.bom.operation_ids. You'll want to display one of the following:

  • The mapped work center or stations, read-only (e.g. Drill Station 1, Galvanization, Powder Coating)

  • The mapped operation names (e.g. Drill, Galvanize, Powder Coat)

For more complicated mappings, please contact us through the support portal.

BOM operations can often include one or more of the following items in the table below:

Destructive operation
Non-Destructive operation

Punching

Painting

Welding

Assembling

Galvanizing

Powder Coating

etc.

Wiring

To read these operations from the BOM, we map to the Odoo property

mrp.bom.operation_id

Create a new Property Mapping with the following settings:

Setting
Value

Property Name / Header

BOM Operations

Accessor

bomOperations

Primary Property

(Unmapped)

Secondary Property

mrp.bom.operation_ids

Update Odoo on Submit

false

Rendering Type

Advanced Multi Select List

List Display Selector

displayName

List Value Selector

id

List items

Here is a sample of what you can insert, but it can be anything, whatever you use most frequently [more on this below]**

[
    {
        "workCenterId": 2,
        "name": "Drill",
        "value": {
            "sequence": 10,
            "name": "Drill",
            "workcenter_id": 2,
            "time_mode": "manual",
            "time_mode_batch": 10,
            "time_cycle_manual": 60
        }
    },
    {
        "workCenterId": 1,
        "name": "Galvanize",
        "value": {
            "sequence": 20,
            "name": "Galvanize",
            "workcenter_id": 1,
            "time_mode": "manual",
            "time_mode_batch": 10,
            "time_cycle_manual": 60
        }
    },
    {
        "workCenterId": 3,
        "name": "Punch",
        "value": {
            "sequence": 30,
            "name": "Punch",
            "workcenter_id": 3,
            "time_mode": "manual",
            "time_mode_batch": 10,
            "time_cycle_manual": 60
        }
    },
]

Enabled

true

Prefer Odoo Value

true

** When creating this list, and you only want to read the values, you'll want to specify at least the Work center id, and the name of the operation. If you also want to write the values back to Odoo, then you'll have to specify the entire object required to add new operations and the default settings for the operation.

Writing BOM operations is explained in the next topic Write BOM Operations

Some BOM operation properties that are available for reading are listed below. The list is not exhaustive and you may customize your own (See the Odoo Configuration options > Models > mrp.routing.workcenter):

Property
Type
Availability
Required for reading in SharpSync

active

bool

16, 17, 18

name

string

16, 17, 18

bom_id

integer

16, 17, 18

workcenter_id

integer

16,17,18

time_mode_batch

integer

16,17,18

time_cycle_manual

integer

16,17,18

note

string

16,17,18

sequence

integer

16,17,18

After adding the new Property Mapping, add an import rule

Setting
Value

Type

import

Name

Text Manipulation

Process for {Primary}

false

Process for Odoo

true

JavaScript expression

if (!s) 
  return [];

if (Array.isArray(s)) 
  return s.map((item) => item.workcenter_id["id"]);

if (typeof s === "string") {
  try {
    const parsed = JSON.parse(s);
    if (Array.isArray(parsed)) {
      return parsed.map((item) => item.workcenter_id["id"]);
    } else {
      console.log("Parsed JSON is not an array, it is " + typeof parsed, parsed);
      return [];
    }
  } catch (e) {
    console.log("Invalid JSON string:", s, "Error:", e.message);
    return [];
  }
}
console.log("Input is not an array or valid JSON string, it is " + typeof s, s);
return [];

Last updated