Skip to content

feat: read organizations back, import from GS1, pick values out of a document - #2

Merged
sboeckelmann merged 2 commits into
mainfrom
feat/organization-read
Oct 3, 2026
Merged

sboeckelmann merged 2 commits into
mainfrom
feat/organization-read

Conversation

@sboeckelmann

Copy link
Copy Markdown
Contributor

Why

Read side for the CRM sync programme: a host that keeps organizations in step with the catalog (the Odoo addon first, see the companion PR in openepcis-odoo) has to read records back, not only publish them.

What

  • Masterdata.get_organization(gln): one record of the caller's tenant, None on 404
  • Masterdata.iter_organizations(): every organization of the tenant, newest change first, paged lazily
  • Masterdata.preview_from_gs1(key) / import_from_gs1(key): GET/POST /masterdata/sync/{key}, the inbound GS1 Germany derivation; Gs1Record mirrors the resolver's MasterDataPreview (product / organization / place)
  • payload.pick(document, path): the reading counterpart of place(), same path grammar; pick_localized() takes one text out of a language map

Known limitation

The resolver sorts by updatedAt but does not return it (WRITE_ONLY on the DTO), so there is no cursor yet. Callers walk the list and compare payload hashes. A modifiedSince filter on the resolver is the follow-up.

Checks

ruff format --check, ruff check, mypy --strict, reuse lint, pytest: 191 passed.

Adds the read side a synchroniser needs, for the CRM sync programme
(Twenty and Odoo kept in step through the catalog):

- get_organization(gln): one record of the caller's tenant, None on 404
- iter_organizations(): every organization, newest change first, paged
- preview_from_gs1(key) / import_from_gs1(key): GET and POST
  /masterdata/sync/{key}, the inbound GS1 Germany derivation

The resolver sorts by updatedAt but does not return it (WRITE_ONLY on
the DTO), so there is no cursor yet: callers walk the list and compare
payload hashes. A modifiedSince filter on the server is the next step.

Signed-off-by: Sven Boeckelmann <sboeckelmann@benelog.com>
pick(document, path) is the reading counterpart of place(), same path
grammar ([] takes the first element); pick_localized() takes one text
out of a language map in a preferred order, falling back to English and
then to whatever is there. A host that synchronises from the catalog back
into its own fields needs both, and the path grammar should stay in one
place.

Signed-off-by: Sven Boeckelmann <sboeckelmann@benelog.com>
@sboeckelmann
sboeckelmann merged commit 2b800c8 into main Oct 3, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant