Skip to content

[19.0][MIG] base_rest: Migration to 19.0 - #686

Open
calpeyser wants to merge 12 commits into
OCA:19.0from
calpeyser:19.0-mig-base_rest
Open

calpeyser wants to merge 12 commits into
OCA:19.0from
calpeyser:19.0-mig-base_rest

Conversation

@calpeyser

Copy link
Copy Markdown
$ curl -X POST -H 'Content-Type: application/json' -d '{}' http://localhost:8069/rest_demo/partner/
HTTP/1.1 500 INTERNAL SERVER ERROR
Content-Type: text/html; charset=utf-8

On 19.0 a request that fails validation returns an HTML 500 instead of JSON, because Odoo 19 removed config.get_misc() and building the error body fails.

base_rest now reads its [base_rest] config section itself, so dev_mode = True still works, and the same request returns a JSON 400. The new test fails before the fix and passes after it, and the suite passes in the OCA CI images.

Continues #613 by NachoAlesLopez.

Prepared with the help of AI

@oca-cla-bot

oca-cla-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@calpeyser

Copy link
Copy Markdown
Author

@NachoAlesLopez this continues your #613, with your two commits kept as they were. The CLA check can't find a signature for [email protected]. Could you sign it, or check that it's on Dynapps' company CLA?

@lmignon lmignon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for the migration... Nevertheless I've a little concern regarding a change into the tests for which I would like some highlight.

Comment thread base_rest/tests/common.py Outdated
Comment on lines +242 to +248
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.setUpRegistry()
cls.base_url = cls.env["ir.config_parameter"].get_param("web.base.url")
cls.registry.enter_test_mode(cls.env.cr)
# pylint: disable=W8106
def setUp(self):
super().setUp()
self.setUpRegistry()
self.base_url = self.env["ir.config_parameter"].get_param("web.base.url")
self.registry_enter_test_mode(register_cleanup=False)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks suspicious to me to have the registry to enter in test mode into the setUp method but leave it into the tearDownClass.... Why do you need to change from setUpClass to setUp?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in a new commit b68a97a. The move to setUp came from the original port in #613 (aca030c). Odoo 19 removed Registry.enter_test_mode(), and its replacement registry_enter_test_mode() is an instance method. Entering per test and leaving per class worked only because CommonCase has one test. With a second test, setUp fails with "Can only patch registry once". The new commit enters test mode in setUpClass with registry_enter_test_mode_cls(), which leaves it in a class cleanup, as HttpCase does. It also adds that second test. CI passes with Odoo and OCB, and the second test fails on the previous head.

@calpeyser

Copy link
Copy Markdown
Author

@lmignon I made the change you asked for in b68a97a. Could you look again when you have time?

The CLA check is red only for the two commits I kept from #613. Their author has not replied yet. If he does not sign, would you accept these two commits under my name, with a note that credits him?

Prepared with the help of AI

@lmignon lmignon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for the fixes, @calpeyser. LGTM!

Regarding the CLA and contribution ownership, the original author must agree to the reassignment of authorship for their commits. I have no authority to make that decision.

@calpeyser

Copy link
Copy Markdown
Author

@lmignon Nacho has not replied on GitHub or by email since 2026-11-05. Would you accept it if I redo the migration myself from 18.0, without his two commits, so the CLA check passes? The description would still credit #613.

@lmignon

lmignon commented Nov 23, 2026 via email

Copy link
Copy Markdown
Contributor

OCA-git-bot and others added 12 commits November 23, 2026 15:38
Disable logging for deprecation.
You might have big projects, with tons of services with no specific decorator,
that are well tested and very stable and you don't want to touch them.
Especially if you plan already to move to v16.
Since this logging can bloat your CI and your log collecting tools,
here is a way to prevent that and get only a msg at boot.

Once enabled, you'll see this msg in the logs only at start up:

'odoo.addons.base_rest.components.service: REST_API_METHOD_FIX_DECORATOR_DEPRECATE_LOG_DISABLE enabled: implicit service methods are deprecated. Disable this env key and enable debug level to have more details.'
Earlier port attempt: OCA#613 by Nacho Ales Lopez
Odoo 19 removed config.get_misc(), so building the JSON body of any
error raised AttributeError and the client got an HTML 500. Read the
[base_rest] section of the config file directly.
BaseRestCase enters registry test mode once in setUpClass, and a class
cleanup leaves it, as HttpCase does. A second test in CommonCase checks
that the registry is still patched after the first test.
The script was also in web.assets_frontend, so every frontend page
without a Swagger element, such as /web/login, raised a TypeError on
load. The /api-docs template already loads the script itself.
@OCA-git-bot OCA-git-bot removed the mod:base_rest_pydantic Module base_rest_pydantic label Nov 23, 2026
@calpeyser

Copy link
Copy Markdown
Author

Redid the migration from 18.0 without the two #613 commits, so the CLA check can pass. The [MIG] commit credits #613. A new commit also takes the Swagger script out of the frontend bundle: it raised an error on every frontend page.

Prepared with the help of AI

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.

5 participants