Integrate translation platform into Odoo 18 as a portal OWL frontend#2094
Conversation
f2b676c to
1ba585a
Compare
|
@copilot This works great now as a backend OWL component in full screen. However I noticed it would be a bad practice because I would need to allow all translation users to become internal users for them to have access to the translation platform. Instead, they should remain external otherwise we would have security concerns and we would need to restrict a lot their permissions which is not ideal. So now I want you to convert those backend components into OWL frontend components. You should inherit the portal frontend view to include a link to the translation platform. The translation platform route and page should display the owl component in full screen and it should be the same as the current backend platform. I won't need the backend action anymore. |
Done in commit 28e1028. Here's what changed: Translators remain external/portal users — New portal route: Portal home link: inherits OWL on the frontend: All assets moved to The backend |
- Add OWL client action component (TranslationPlatform) registered as
'translation_platform' in the actions registry
- Add DAO modules (letter_dao, translator_dao, settings_dao) using
useService('orm') instead of XML-RPC
- Add reusable OWL components: loader, modal, signal-problem, child-modal,
content-editor, letter-viewer, languages-pick-modal, translator-button
- Add page components: home, letters, letter-edit, translators
- Add ir.actions.client record + menu item for translator users
- Remove website dependency; fix translation_url computation
- Remove share=True from group_user to enable backend access
- Set Translation Platform as home action for translator users on create
- Add migration script to set home action for existing translators
- Redirect legacy /translation-platform route to /odoo/translation-platform"
Agent-Logs-Url: https://github.com/CompassionCH/compassion-modules/sessions/e2c2193b-7ccb-4cc2-924e-721f15cf8a53
Co-authored-by: ecino <8435180+ecino@users.noreply.github.com>
…l users
- Translators are now portal (share=True) users, not internal users
- Assets moved from web.assets_backend to web.assets_frontend
- New rpc.js: direct JSON-RPC helper replacing useService('orm')
- New notification.js: Bootstrap alert helper replacing useService('notification')
- All DAOs and components no longer depend on backend Odoo services
- New portal controller at /my/translation-platform with group check
- New portal_templates.xml: portal home link + full-screen translation platform page
- OWL app now mounts via whenReady() on #tp-app-root portal container
- Restored share=True for group_user; removed implied internal group
- Fixed translator_admin_rule to use group_manager (not group_user)
- Removed action_id assignment from translation_user.py create/write/unlink
- Removed backend ir.actions.client action from manifest
- Updated migration script to clear action_id and ensure portal group membership
- Legacy /translation-platform routes redirect to /my/translation-platform
Agent-Logs-Url: https://github.com/CompassionCH/compassion-modules/sessions/f0e5215c-b7c5-4204-b1f6-1d67de29a31d
Co-authored-by: ecino <8435180+ecino@users.noreply.github.com>
1ea0d21 to
0809110
Compare
|
@copilot Great module but the xml used in the OWL components is integrated in the JS code which is not ideal for translations and code maintainability. Please move out all templates in dedicated xml files as suggested by Odoo documentation: "We define here the template in the javascript code, with the help of the xml helper. However, it is only useful to get started. In practice, templates in Odoo should be defined in an xml file, so they can be translated. In that case, the component should only define the template name. In practice, most components should define 2 or 3 files, located at the same place: a javascript file (my_component.js), a template file (my_component.xml) and optionally a scss (or css) file (my_component.scss). These files should then be added to some assets bundle. The web framework will take care of loading the javascript/css files, and loading the templates into Owl. Here is how the component above should be defined: import { Component, useState } from "@odoo/owl"; class MyComponent extends Component { } Template names should follow the convention addon_name.ComponentName." Can you also import back all translations that were defined in the initial project https://github.com/CompassionCH/translation-platform-web/tree/main/src/i18n ? It should be correctly placed in the po files of the sbc_translation module. |
- Created 13 XML template files (one per component/page) following Odoo convention: sbc_translation.ComponentName - Removed inline xml`` template literals from all 14 .esm.js files; each class now references its template by name - Registered all XML template files in web.assets_frontend before their companion JS files in __manifest__.py - Added 65 UI translations (fr_CH and de) ported from the old translation-platform-web i18n/fr_CH.json and i18n/de_DE.json files - Fixed t-out expressions: replaced `or` operator with ternary for safer/more explicit fallback values - Fixed two French translation issues: 'Gères' -> 'Gère', removed trailing period from 'Your current translation skills' Agent-Logs-Url: https://github.com/CompassionCH/compassion-modules/sessions/06d5a6dc-67a6-4817-94b5-b978b3d89cd9 Co-authored-by: ecino <8435180+ecino@users.noreply.github.com>
Done in commit d3d65f8. Here's what was implemented: Template extraction: Created 13 dedicated XML template files (one per component/page file), following the Odoo convention i18n translations: Fetched the Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
- Attempt to fix translations without success
1cccd41 to
4afe7db
Compare
Replaces the standalone Vite/TypeScript web app (
translation-platform-web) with an OWL frontend component served via the Odoo portal, eliminating the separate domain, JWT auth, and XML-RPC layer. Translator users remain external/portal users and access the translation UI at/my/translation-platform.Frontend (
sbc_translation/static/src/)rpc.esm.js: lightweight JSON-RPC helper that calls/web/dataset/call_kwwith the session cookie, replacinguseService("orm")across all DAOs and components.notification.esm.js: Bootstrap alert helper replacinguseService("notification").models/):letter_dao.esm.js,translator_dao.esm.js,settings_dao.esm.js— rewritten to userpc.esm.jsagainst the existing Python API methods. Record-level calls use the[[id], ...args]call_kw convention.components/): each component is split into a.esm.jsclass file and a companion.xmltemplate file following Odoo conventions (sbc_translation.ComponentName). Covers: modal, loader, split-pane letter viewer (PDF + editor), content editor (paragraph-by-paragraph translation with auto-save), signal-problem, child-modal, skill/language picker.pages/): same two-file structure for home dashboard (skill cards + letter links), letters list (sortable/filterable/paginated), letter-edit (core translation UI, Ctrl+S + 30s auto-save), translators admin.translation_platform.esm.js+translation_platform.xml): mounts the OWL app viawhenReady()on#tp-app-root; state-based navigation replaces the standalone History API router.All XML template files are registered in
web.assets_frontendbefore their companion JS files so the Odoo web framework loads them into OWL automatically.Portal / Odoo integration
templates/portal_templates.xml: inheritsportal.portal_my_hometo add a "Translation Platform" link; defines the full-screenportal_translation_platformtemplate with a#tp-app-rootmount container.controllers/main.py: new/my/translation-platformportal route (auth=user,group_usercheck); legacy/translation-platform/*routes 301-redirect to/my/translation-platform.__manifest__.py: addsportaldependency; enumerates all new static assets (XML templates first, then JS) underweb.assets_frontend; removesdata/website.xml.security/ir_groups.xml: restoresshare = Trueforgroup_user— translators remain portal/external users; removes impliedbase.group_user(internal user).security/access_rules.xml:translator_admin_rulenow scoped togroup_manageronly, preventing regular translators from reading all translator records.models/translation_user.py:create()assignsgroup_userand setstranslator_id; no backendaction_idoverride.models/correspondence.py:translation_urlandget_letter_infono longer reference thetranslation_websiterecord; useweb.base.urldirectly.i18n
65 UI strings (labels, buttons, child-protection policy text, notification messages) from the original
translation-platform-webproject'sfr_CH.jsonandde_DE.jsonfiles have been ported intoi18n/fr_CH.poandi18n/de.po.Migration
migrations/18.0.1.1.0/post_migrate.pyclears any previously setaction_idoverrides and ensures all existing active translators havegroup_usermembership.