Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions endpoint_route_handler/models/endpoint_route_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class EndpointRouteHandler(models.AbstractModel):
index=True,
compute="_compute_route",
inverse="_inverse_route",
precompute=True,
readonly=False,
store=True,
copy=False,
Expand Down
22 changes: 22 additions & 0 deletions endpoint_route_handler/tests/test_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# @author: Simone Orsi <simone.orsi@camptocamp.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from contextlib import contextmanager
from unittest.mock import patch

from odoo import api, modules
from odoo.tests import common
Expand Down Expand Up @@ -50,6 +51,27 @@ def test_as_tool_base_data(self):
new_route.route += "/new"
self.assertNotEqual(new_route.endpoint_hash, first_hash)

def test_route_field_precomputed(self):

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.

do we really need this test? It's kind of testing an odoo core feature 🤔

@AungKoKoLin1997 AungKoKoLin1997 Jul 15, 2026

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.

My purpose is to be sure the fix is working well.

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.

@simahawk
To clarify further — the test is not meant to verify Odoo's precompute mechanism itself. It's a regression guard to ensure precompute=True stays on the route field. If someone removes it during a future migration or refactor, this test will catch the breakage. Without it, the only way to notice would be a failure in a downstream module at runtime.

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.

ok, you could rewrite the docstring of the test by removing repeated information (sounds quite verbose ATM for little value) and add a synthetic version of the purpose that you've just explained.

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.

@simahawk I updated the docstring.

"""Regression guard: ensure ``precompute=True`` stays on ``route``.

Without it, downstream modules that derive ``route`` via compute
would hit a "Missing required value" error at INSERT time.
"""
Model = type(self.env["endpoint.route.handler.tool"])

def _fake_compute_route(self):
for rec in self:
rec.route = "/precompute/probe"

with patch.object(Model, "_compute_route", _fake_compute_route):
rec = self.env["endpoint.route.handler.tool"].create(
{
"name": "Precompute test",
"request_method": "GET",
}
)
self.assertEqual(rec.route, "/precompute/probe")

@mute_logger("odoo.addons.base.models.ir_http")
def test_as_tool_register_single_controller(self):
new_route = make_new_route(self.env)
Expand Down
Loading