Skip to content

[19.0][ADD] uom_preset#275

Open
bosd wants to merge 1 commit into
OCA:19.0from
bosd:19.0-add-uom_preset
Open

[19.0][ADD] uom_preset#275
bosd wants to merge 1 commit into
OCA:19.0from
bosd:19.0-add-uom_preset

Conversation

@bosd

@bosd bosd commented May 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds uom_preset, an abstract-model registry that translates supplier-specific UoM codes to UN/CEFACT Recommendation 20 codes (via uom_unece), so they resolve to uom.uom records.

The module is intentionally narrow in scope: it only covers nomenclatures that do not use UN/CEFACT codes natively. For SCSN-style or any other Rec 20-conformant supplier flow, callers should look up uom.uom.unece_code directly via uom_unece — no preset is needed.

Vocabularies shipped

  • pricat (11 entries) — the Dutch Pricat catalogue/order exchange format, sourced verbatim from INDI's public OCI-PunchOut documentation: https://www.indi.nl/nl-nl/slim-inkopen/erp-connecties/oci-punchout — section Eenheden-overzicht.
  • x12_355 (160 entries) — ANSI ASC X12 element 355, used in US retail and manufacturing EDI. Only the entries where the X12 code differs from the UN/CEFACT Rec 20 code are shipped; pass-through entries are dropped so callers fall through to uom_unece directly. Source: Ariba Network UOM Mapping for ANSI X12 (SAP, 2014, PDF).

API

uom = self.env["uom.preset"]._resolve("pricat", "STU")
# -> uom.uom record whose unece_code == "C62", or empty recordset on miss.

Resolution is strict: an unknown vocabulary or a code missing from the chosen vocabulary returns an empty recordset. The caller chains its own fallback.

To add a vocabulary in a follow-up module, inherit uom.preset and extend _uom_preset_vocabularies / _uom_preset_selection (see USAGE).

Tests

16 cases including a guard that fails if anyone adds a pass-through entry to either dict (catches the "this vocab is just uom_unece again" mistake before review).

@bosd bosd force-pushed the 19.0-add-uom_preset branch from e52e058 to bbc8ce5 Compare May 14, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants