openepcis_connector_events: visibility events

Every validated transfer becomes an EPCIS 2.0 ObjectEvent, packing an AggregationEvent under an SSCC, a return a TransactionEvent, and a wrong report an error declaration. Three settings decide what is reported: the company switch, the operation type, the location, and an outbox keeps the warehouse from ever waiting on the repository. Partners' events come back into an inbox that shows and, where two settings agree, posts.

Master data says what a product is. An EPCIS event says what became of one particular item: that it was received, packed, shipped, sold, returned or turned into something else. Together the two are what a scanned serial number can answer. This addon reports Odoo's warehouse operations as such events and reads back what partners report about the same goods.

Moduleopenepcis_connector_events
Depends onopenepcis_connector_stock; the Python package epcis_event_hash_generator
InstallsBy hand, since reporting movements to a shared repository is a decision each company takes for itself
Talks toThe EPCIS 2.0 repository, a different service from the resolver and usually on a different host
Sourceopenepcis-odoo · LGPL-3

What is reported

What happened in OdooEventBusiness step
A transfer is validatedObjectEvent, OBSERVEFrom the operation type: receiving, shipping, storing, …
Goods are put into a packageAggregationEvent, ADD, parent = the package's SSCCpacking
A package is emptied, by picking from it or by UnpackAggregationEvent, DELETEunpacking
Cases go onto a pallet (Odoo 19, nested packages)AggregationEvent, children = SSCCspacking
Goods come back on a returnTransactionEvent, DELETE, which releases the shipment they went out onreceiving, disposition returned
A manufacturing order is finishedTransformationEvent, see manufacturing eventscommissioning
A report was wrongThe same event again, with an errorDeclaration of did_not_occur(none)

Each event involves a few choices about how Odoo's data is expressed in EPCIS, and four of them are worth knowing.

Serial numbers and lots are treated differently. A serial identifies one unit and goes into the epcList as an SGTIN, whereas a lot identifies a set and goes into the quantityList as an LGTIN. Untracked goods count as a set too, namely the trade item itself, so a warehouse that tracks nothing still produces useful events.

Only published products appear in events. An identifier that resolves nowhere would leave a scan with an event and no product behind it, so unpublished products are left out and the event still describes everything else that moved.

Every event carries a read point, although EPCIS makes the field optional, because an event that says something happened without saying where answers only half the question. If the locations of a transfer carry no GLN, the transfer is reported in its chatter, where somebody can fix the location.

The Origin field becomes the business transaction, so downstream readers can match on the reference the warehouse actually typed. A delivery without a reference is named after the transfer.

Three settings, each where the fact lives

The company switch. Under Settings → General Settings → OpenEPCIS → Report visibility events you turn reporting on and enter the repository's address and your GS1 company prefix. Test capture checks that the offline token the connector already holds is also allowed to capture events. Publishing master data and capturing events are two separate rights, and a token can hold one without the other.

Figure 1: The switch, the repository address, and the company prefix, which is used for SSCCs and nothing else

SSCCs are minted from this prefix. A company allocates its SSCCs itself, unlike GTINs, which are drawn from a registry, and only has to make sure that it never repeats one. The addon therefore mints them locally from a sequence at the moment a package comes into being.

The operation type carries the why. Odoo knows that a transfer is "incoming", but it has no notion that GS1 calls this receiving with the goods in_progress. Two fields on every operation type hold the business step and the disposition. They are pre-filled from Odoo's own codes and the sequence prefix, and once somebody has chosen a different value, the pre-fill never overwrites it. A third flag, Report as EPCIS events, lets you exclude an operation type entirely.

Figure 2: Business step and disposition, seeded from the operation's codes

Operation typeOdoo codeBusiness stepDisposition
Receiptsincomingreceivingin_progress
Pick / Pack / Quality Controlinternalpicking / packing / inspectingin_progress
Storageinternalstoringsellable_accessible
Delivery Ordersoutgoingshippingin_transit
Manufacturingmrp_operationcommissioningactive

The location carries the where. EPCIS expects an SGLN, so a location needs a GLN, which Odoo's locations do not have. They do form a tree, though: set the GLN on the warehouse, the loading bay or the shop floor, and every location underneath inherits it by walking up the tree. A single number thus makes a whole site addressable. Odoo's own GS1 barcode nomenclature binds AI 414 to a location, so the GLN you enter here is also what a scanner reads off a GS1 location label.

The outbox

Validating a transfer never waits for the network. Pressing Validate writes rows into an outbox and returns at once, and a scheduled action delivers the rows every minute.

Figure 3: One warehouse day as twelve rows

Delivery produces two separate answers. Accepted means the repository took the document, and Captured means it stored it. Capture is asynchronous: the repository validates afterwards and may still refuse the document. A queue that deleted its row on the 202 would therefore report success for events that were thrown away minutes later. Each row instead keeps its capture job and asks again on the next run. After five attempts it stops asking and marks the event as unconfirmed.

Each row shows two identifiers with different jobs. The expected event ID is the canonical CBV event hash over everything the event asserts. Anyone holding the event can recompute it, which lets two companies name the same observation without any prior agreement. Odoo computes it only to recognise its own events when they come back and sends the document without it, because the canonical form is defined once, by the repository. The idempotency key is private bookkeeping derived from the database, the transfer and the identifiers, and it ensures that the same movement cannot enter the outbox twice. It never leaves Odoo.

Taking a report back

Once an event is in a repository it stays there; EPCIS withdraws it with an error declaration. The addon sends the original event again with errorDeclaration.reason = did_not_occur. Declaration fields are excluded from the hash, so the correction carries the same identity and the repository knows which event is meant, even though Odoo never learns the name the repository gave it. The original stays on its row, greyed out and marked as corrected.

The inbox

Events also come in, when partners' systems report on our lots and packages. A scheduled action reads the repository every five minutes, starting from a watermark based on the repository's own write clock, so an outage costs one run and needs no reconciliation. It shows what it finds on the lot, on the package, and at the point where Odoo's own traceability report stops at the company boundary.

The inbox never moves stock. A partner's event is an observation made by a third party, while Odoo's stock is a valued figure that ends up in the books. Posting observations into it would make the closing depend on someone else's data quality. Three settings under What we read back keep the inbox manageable:

  • which events to keep: everything the credential may see, only identifiers under our own prefix, or only what can be placed in this database;
  • events per run;
  • pages per run, which acts as a brake so that a day of catching up never turns into one unbounded transaction.

The one exception

An incoming event may advance a transfer that is already open, reserved and waiting for exactly this confirmation, for example a supplier confirming his own despatch or a customer booking a receipt. Even then it never creates a document, never creates stock, never reopens anything closed and never touches quantities. The worst a wrong event can do is validate a transfer a day early, which is visible, attributable and reversible like any other mistaken validation.

Even that requires two settings to agree, so that neither one is a single point of trust:

  • The operation type says what an incoming event may do at all: Ignore, Show only (the default), Propose a posting, or Post automatically.
  • The partner says on whose behalf. May move our transfers sits on the contact, next to the GLN that identifies the partner in the events, and is off by default.

Before any of this runs for real, it runs as a rehearsal. While the operation type's Observe only flag is set, the whole decision is made and written to the log and only the last step is skipped. Somebody reads a week of that log and then clears the flag.

See it end to end

A warehouse day walks through a receipt, a pallet, a delivery, a return, a manufacturing order and a withdrawal, each with the event it produces, copied from the outbox of the instance in the screenshots.

Last updated: