Skip to content

Fix inherited schema fields missing for multi-schema Dexterity types#89

Merged
ramonski merged 3 commits into
2.xfrom
missing-fields-dexterity
Jun 3, 2026
Merged

Fix inherited schema fields missing for multi-schema Dexterity types#89
ramonski merged 3 commits into
2.xfrom
missing-fields-dexterity

Conversation

@xispa
Copy link
Copy Markdown
Member

@xispa xispa commented Jun 3, 2026

Description of the issue/feature this PR addresses

When the object being serialized is a Dexterity (DX) content type whose schema interface inherits from another schema interface, only the fields declared directly on the type's own interface were returned. Fields declared by the parent interface(s) were silently dropped from the API response.

The root cause was the use of schema.names() in get_fields, which returns only the names declared directly on the interface — inherited fields require names(all=True). senaite.core's api.get_fields already resolves this correctly (it uses plone.supermodel's getFieldsInOrder, which walks the interface bases, and also folds in behavior fields), so this PR delegates to it instead of re-implementing the field collection.

senaite.core.content.supplier.Supplier is a representative multi-schema DX type: its ISupplierSchema inherits from IOrganizationSchema.

Current behavior before PR

For a multi-schema DX type, the JSON response (and get_fields / get_field) expose only the fields declared on the leaf schema interface. Inherited fields (e.g. tax_number, declared on the parent IOrganizationSchema) are missing, so they cannot be read, searched or projected through the API.

Desired behavior after PR is merged

All schema fields are returned — those declared directly on the type's interface, those inherited from parent interfaces, and those contributed by assigned behaviors. get_fields, get_field and the Dexterity/AT data providers all derive their field set from a single source (senaite.core's api.get_fields), keeping the field list and per-field lookups consistent.

--
I confirm I have tested the PR thoroughly and coded it according to PEP8
standards.

@xispa xispa added Bug 🐞 Something is broken P0: Critical 🤯 Drop everything labels Jun 3, 2026
Copy link
Copy Markdown
Contributor

@ramonski ramonski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

@ramonski ramonski merged commit dd2c845 into 2.x Jun 3, 2026
2 checks passed
@ramonski ramonski deleted the missing-fields-dexterity branch June 3, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug 🐞 Something is broken P0: Critical 🤯 Drop everything

Development

Successfully merging this pull request may close these issues.

2 participants