Odoo 18 migration - T3173 migrate auth external#51
Conversation
- vite.config.js: server. proxy /auth and /xmlrpc -> VITE_DEV_PROXY_TARGET (default http://localhost:8069). Lets npm run dev work against a local Odoo without CORS hacks, v18's /xmlrpc/2/* declares no cors= attribute, so cross-origin XML-RPC fails preflight in the browser. The proxy makes the browser see same-origin requests instead. - .env: VITE_ODOO_URL default changed from a placeholder to "" with guidance, recommended setting both for local dev (proxy intercepts relative URLs) and for the production deployment where Odoo serves the SPA from static/tp/ (also same-origin). Added VITE_DEV_PROXY_TARGET. - README: added "Running against Odoo 18" section documenting the three deployment modes (Odoo-served, dev with Vite proxy, true cross-origin which requires an Odoo-side CORS patch). The legacy v12/v14 source-patch instructions are kept for historical reference. The webapp's RPC contracts already match the v18 auth_external controllers, no changes to OdooAPI.ts, the store, or any DAO.
There was a problem hiding this comment.
Code Review
This pull request introduces support for Odoo 18 by implementing a Vite dev proxy to handle authentication and XML-RPC requests, effectively bypassing CORS issues during local development. Documentation has been updated to reflect these changes and provide guidance on deployment modes. Additionally, the data access objects for letters and translators were updated to use the search_count method instead of a count parameter in the search method. Feedback suggests adding fallback values to these count requests to ensure type safety and prevent runtime errors if the API returns undefined.
| const [letterIds, total] = await Promise.all([ | ||
| OdooAPI.execute_kw('correspondence', 'search', searchParams), | ||
| OdooAPI.execute_kw('correspondence', 'search', [...searchParams, true]) as Promise<number> | ||
| OdooAPI.execute_kw('correspondence', 'search_count', countParams) as Promise<number>, |
There was a problem hiding this comment.
The OdooAPI.execute_kw method can return undefined if the request fails. Since the total property in the returned object is expected to be a number (per the ListResponse interface), it is safer to provide a default value of 0 to avoid potential runtime issues in UI components (like pagination) and to maintain type safety.
| OdooAPI.execute_kw('correspondence', 'search_count', countParams) as Promise<number>, | |
| OdooAPI.execute_kw('correspondence', 'search_count', countParams).then((res) => res ?? 0) as Promise<number>, |
| const [translatorIds, total] = await Promise.all([ | ||
| OdooAPI.execute_kw('translation.user', 'search', searchParams), | ||
| OdooAPI.execute_kw('translation.user', 'search', [...searchParams, true]) as Promise<number> | ||
| OdooAPI.execute_kw('translation.user', 'search_count', countParams) as Promise<number>, |
There was a problem hiding this comment.
Similar to the LetterDAO, the total count should have a fallback value. If the API call fails, execute_kw returns undefined, which violates the number type requirement for the total field in the response. Defaulting to 0 ensures robustness.
| OdooAPI.execute_kw('translation.user', 'search_count', countParams) as Promise<number>, | |
| OdooAPI.execute_kw('translation.user', 'search_count', countParams).then((res) => res ?? 0) as Promise<number>, |
Confidence Score: 4/5Safe to merge into the correct target branch — all logic changes are correct and self-consistent. The search → search_count migration is correct: countParams passes only the domain, which is what Odoo 18 search_count expects. The Vite proxy config is correct and scoped to the dev server. The only finding is a trivial missing-newline in .env (P2). No files require special attention; .env has a minor trailing-newline nit. Important Files Changed
Reviews (1): Last reviewed commit: "[MIG] adapt cors guidance" | Re-trigger Greptile |
| # Where `npm run dev` proxies /auth/* and /xmlrpc/* to. Defaults to | ||
| # http://localhost:8069 if unset. Override if your Odoo runs on a | ||
| # different port or host. | ||
| VITE_DEV_PROXY_TARGET="http://localhost:8069" No newline at end of file |
There was a problem hiding this comment.
The file still ends without a trailing newline (\ No newline at end of file). Some tooling (e.g. dotenv parsers, git diff, linters) can misbehave or produce noisy diffs when a file is missing the final newline.
| VITE_DEV_PROXY_TARGET="http://localhost:8069" | |
| VITE_DEV_PROXY_TARGET="http://localhost:8069" |
Adaptations for Odoo 18.0
DO NOT MERGE THIS YET
Dependencies:
CompassionCH/compassion-modules#2096
CompassionCH/compassion-switzerland#1756