From 7925aa7b4ac7bd3ca650781aeb9241806ed1b444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Andreatta?= Date: Fri, 27 Mar 2026 21:02:56 +0100 Subject: [PATCH] [FIX] core: support HEAD requests and virtualenv check - Add head method to RESTConnector - Fix virtualenv check in LocalDatabase --- odev/_version.py | 2 +- odev/common/connectors/rest.py | 14 +++++++++++++- odev/common/databases/local.py | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/odev/_version.py b/odev/_version.py index 5626e70..73bc621 100644 --- a/odev/_version.py +++ b/odev/_version.py @@ -22,4 +22,4 @@ # or merged change. # ------------------------------------------------------------------------------ -__version__ = "4.27.0" +__version__ = "4.27.1" diff --git a/odev/common/connectors/rest.py b/odev/common/connectors/rest.py index db22fb0..28e8ce8 100644 --- a/odev/common/connectors/rest.py +++ b/odev/common/connectors/rest.py @@ -307,7 +307,7 @@ def _request( @abstractmethod def request( self, - method: Literal["GET"] | Literal["POST"], + method: Literal["GET", "POST", "HEAD"], path: str, authenticate: bool = True, params: dict | None = None, @@ -348,6 +348,18 @@ def post(self, path: str, params: dict | None = None, authenticate: bool = True, """ return self.request("POST", path, params=params, authenticate=authenticate, **kwargs) + def head(self, path: str, params: dict | None = None, authenticate: bool = True, **kwargs) -> Response: + """Perform a HEAD request to the endpoint. + Authentication is handled automatically using the Odoo credentials stored in the secrets vault. + + :param path: The path to the resource. + :param params: The parameters to pass to the request. + :param kwargs: Additional keyword arguments to pass to the request. + :return: The response from the endpoint. + :rtype: requests.Response + """ + return self.request("HEAD", path, params=params, authenticate=authenticate, **kwargs) + def download(self, path: str, file_path: Path, progress_message: str = "Downloading", **kwargs) -> Path: """Download a file from the endpoint. diff --git a/odev/common/databases/local.py b/odev/common/databases/local.py index b574839..6e83a50 100644 --- a/odev/common/databases/local.py +++ b/odev/common/databases/local.py @@ -125,7 +125,7 @@ def venv(self) -> PythonEnv: if self._venv is None: info = self.store.databases.get(self) - if info is None: + if info is None or not info.virtualenv: if self.version is None: return PythonEnv()