[19.0][ADD] endpoint_json2 - #135
Open
AungKoKoLin1997 wants to merge 1 commit into
Open
Conversation
AungKoKoLin1997
force-pushed
the
19.0-add-endpoint_json2
branch
2 times, most recently
from
May 26, 2026 04:56
ea70161 to
bd16156
Compare
Contributor
|
@AungKoKoLin1997 interesting approach. Early feedback: I don't think the mixin is the right place as it can be inherited by all extending models (eg: edi_endpoint). I tend to say |
AungKoKoLin1997
force-pushed
the
19.0-add-endpoint_json2
branch
from
May 27, 2026 05:07
bd16156 to
26ae1fd
Compare
Author
|
@simahawk Thanks for your feedback. I updated to use |
smorita7749
reviewed
Jun 2, 2026
AungKoKoLin1997
force-pushed
the
19.0-add-endpoint_json2
branch
from
June 2, 2026 09:24
26ae1fd to
d74377a
Compare
smorita7749
approved these changes
Jun 2, 2026
smorita7749
left a comment
There was a problem hiding this comment.
Functional review: LGTM
The flow creating endpoint and getting response is properly working.
Contributor
|
@ivantodorovich can you have a look at this? |
yostashiro
force-pushed
the
19.0-add-endpoint_json2
branch
from
July 26, 2026 14:13
d74377a to
3b7080c
Compare
yostashiro
approved these changes
Jul 26, 2026
yostashiro
left a comment
Member
There was a problem hiding this comment.
Code review and functional test.
yostashiro
added a commit
to qrtl/ocj-oca
that referenced
this pull request
Aug 9, 2026
…lds (#31) [QT6769](https://www.quartile.co/web#id=6769&cids=3&menu_id=506&action=1457&model=project.task&view_type=form) Lets an endpoint whose method is not `read`/`search_read` declare its response fields. ### Problem `_check_json2_response_fields` validated every response field against the target model's fields, for every endpoint. That is correct when the method is `read` or `search_read`, whose result rows are made of model fields. It is wrong for any other method: the keys are the method's own, and the model has no way to know them. A method returning a derived value therefore could not name it at all — declaring it raised `ValidationError`, so the only way forward was to leave `json2_response_fields` empty. That turns off filtering and aliasing entirely and leaves the payload implicit in the Python, invisible to anyone reading the endpoint record. ### Change - Plain names are validated only for the methods in `FIELD_READING_METHODS` (`read`, `search_read`). That is a **policy list, not a taxonomy of the ORM** and is not meant to grow: `read_group` also returns model field values and is deliberately excluded, since its rows carry keys of its own (`__count`, `__domain`) too. A module wanting its own method checked should constrain it where the payload is defined, which can pin the exact keys rather than merely "is a field of the model". - Dotted specs stay validated whatever the method is: `_json2_resolve_dotted_fields` resolves the base against `Model._fields` before fetching the related rows, so a base that is not a relational field can never resolve. - The constraint now also depends on `json2_method`, so switching an endpoint back to `search_read` re-runs the check instead of leaving behind keys the model does not have. Nothing changes at execution time: filtering, aliasing and dotted resolution were already applied to the result of any method, not only `search_read`. ### Notes - `README.rst` is not regenerated — the `oca-gen-addon-readme` hook is commented out in this repository's `.pre-commit-config.yaml` (line 57), so `readme/CONFIGURE.md` is updated but the generated file is left alone rather than hand-edited. - The same change is wanted upstream in OCA/web-api#135, which is still open. - I could not execute the tests locally: `addons_path` is empty in this workspace's `odoo.conf` and a fresh database registered 667 modules with no `endpoint*` among them, so the namespace path did not include the repositories. Relying on CI here.
AungKoKoLin1997
force-pushed
the
19.0-add-endpoint_json2
branch
2 times, most recently
from
August 10, 2026 03:07
68f5b7d to
bca7295
Compare
Author
|
I added a few changes.
|
AungKoKoLin1997
force-pushed
the
19.0-add-endpoint_json2
branch
from
August 10, 2026 03:46
bca7295 to
2c6f947
Compare
Assisted-by: Claude Opus 5
AungKoKoLin1997
force-pushed
the
19.0-add-endpoint_json2
branch
from
August 10, 2026 03:50
2c6f947 to
ec926e3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This module adds
exec_mode="json2to the endpoint framework, enabling declarative JSON-2 API endpoint configuration. Select a model, method, and parameters — the module handles dispatch, parameter validation, access control, and result filtering. A code snippet can be used as an alternative to a model method for quick, ad-hoc logic.@qrtl QT6769