Skip to content

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

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

calpeyser wants to merge 5 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

NachoAlesLopez and others added 4 commits November 5, 2026 16:08
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.
Ignore the Chrome zombie and the libsass 0.20 frontend warnings, as
OCA/web and OCA/server-tools do on 19.0.
@oca-cla-bot

oca-cla-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not 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 nacho.aleslopez@dynapps.eu. 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.

Odoo 19 removed Registry.enter_test_mode(). Use
registry_enter_test_mode_cls(), which also leaves test mode in a
class cleanup, as HttpCase does. The per-test enter with a
per-class leave failed on a class with more than one test.
@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:base_rest_pydantic Module base_rest_pydantic mod:base_rest Module base_rest series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants