From 2ef4621a896c2f890b563832fc895f2434788e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorem=20Ju=C3=A1rez?= Date: Tue, 1 Sep 2026 17:38:33 -0600 Subject: [PATCH] =?UTF-8?q?El=20lanzador=20tiene=20por=20d=C3=B3nde=20cerr?= =?UTF-8?q?ar=20sesi=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/src/webclient/beyond_launcher.js | 13 +++++++ .../static/src/webclient/beyond_launcher.scss | 32 ++++++++++++++++- .../static/src/webclient/beyond_launcher.xml | 22 ++++++++++++ addons/beyond_base/tests/test_panel_navbar.py | 34 +++++++++++++++++++ 4 files changed, 100 insertions(+), 1 deletion(-) diff --git a/addons/beyond_base/static/src/webclient/beyond_launcher.js b/addons/beyond_base/static/src/webclient/beyond_launcher.js index 464e621..90f6535 100644 --- a/addons/beyond_base/static/src/webclient/beyond_launcher.js +++ b/addons/beyond_base/static/src/webclient/beyond_launcher.js @@ -3,6 +3,7 @@ import { patch } from "@web/core/utils/patch"; import { useBus } from "@web/core/utils/hooks"; import { useRef } from "@odoo/owl"; import { useDropdownState } from "@web/core/dropdown/dropdown_hooks"; +import { browser } from "@web/core/browser/browser"; import { NavBar } from "@web/webclient/navbar/navbar"; import { WebClient } from "@web/webclient/webclient"; @@ -28,6 +29,18 @@ patch(NavBar.prototype, { this.beyondLauncherToggle.el?.focus(); }); }, + + /** + * Cerrar sesión desde el lanzador. + * + * El enlace ya lleva su `href`, así que si esto no corriera la salida + * funcionaría igual. Lo único que agrega es avisarle al service worker, + * que es lo que hace el menú de usuario de Odoo: sin ese aviso, una + * aplicación instalada se queda con la sesión vieja en caché. + */ + cerrarSesion() { + browser.navigator.serviceWorker?.controller?.postMessage("user_logout"); + }, }); patch(WebClient.prototype, { diff --git a/addons/beyond_base/static/src/webclient/beyond_launcher.scss b/addons/beyond_base/static/src/webclient/beyond_launcher.scss index fe7c1f0..1de2853 100644 --- a/addons/beyond_base/static/src/webclient/beyond_launcher.scss +++ b/addons/beyond_base/static/src/webclient/beyond_launcher.scss @@ -209,9 +209,39 @@ $beyond-launcher-vidrio-bajo: rgba(255, 255, 255, 0.35); .beyond_launcher_brand { flex: none; display: flex; - justify-content: flex-end; + // La firma se queda a la derecha y cerrar sesión ocupa la izquierda: + // `space-between` en vez de empujar la firma, para que la salida no + // quede pegada a la marca. + justify-content: space-between; + align-items: center; padding: 4px 22px 14px; + .beyond_launcher_salir { + display: flex; + align-items: center; + gap: 8px; + // Alto de dedo: esta pantalla se usa en tableta de mostrador. + min-height: 44px; + padding: 0 14px; + border-radius: 10px; + font-size: 14px; + font-weight: 600; + color: $beyond-ink; + text-decoration: none; + opacity: 0.75; + + svg { + width: 20px; + height: 20px; + } + + &:hover, &:focus-visible { + opacity: 1; + background: rgba(35, 32, 29, 0.06); + color: $beyond-ink; + } + } + span { font-size: 13px; font-weight: 600; diff --git a/addons/beyond_base/static/src/webclient/beyond_launcher.xml b/addons/beyond_base/static/src/webclient/beyond_launcher.xml index 963b2b1..3fe0cf1 100644 --- a/addons/beyond_base/static/src/webclient/beyond_launcher.xml +++ b/addons/beyond_base/static/src/webclient/beyond_launcher.xml @@ -212,7 +212,29 @@ +
+ + + Cerrar sesión + Powered by Collina Systems
diff --git a/addons/beyond_base/tests/test_panel_navbar.py b/addons/beyond_base/tests/test_panel_navbar.py index a5ff3e7..b3f49f5 100644 --- a/addons/beyond_base/tests/test_panel_navbar.py +++ b/addons/beyond_base/tests/test_panel_navbar.py @@ -2,6 +2,7 @@ from lxml import etree from odoo.tests import TransactionCase, tagged +from odoo.tools import file_open from odoo.tools.template_inheritance import apply_inheritance_specs BUNDLE = 'web.assets_backend' @@ -108,3 +109,36 @@ class TestPanelNavbar(TransactionCase): marca = resultado.xpath("//DropdownItem[@t-esc='currentApp.name']") self.assertTrue(marca, "el título nativo de la app no debe eliminarse") self.assertIn('!beyondEsPanel', marca[0].get('t-if')) + + +@tagged('post_install', '-at_install') +class TestBeyondLanzadorSalida(TransactionCase): + """El lanzador tiene por dónde salir. + + Quien opera desde una tablet de mostrador ve esta pantalla y nada más: + el menú de usuario de Odoo no es una puerta aquí, así que sin este + enlace no había forma de cerrar el turno (encargo del 01-sep-2026). + """ + + def _lanzador(self): + with file_open('beyond_base/static/src/webclient/beyond_launcher.xml') as f: + return f.read() + + def test_el_lanzador_ofrece_cerrar_sesion(self): + plantilla = self._lanzador() + self.assertIn('Cerrar sesión', plantilla) + + def test_la_salida_es_un_enlace_de_verdad(self): + """Un `` y no un botón con JavaScript: si los assets fallan, + que es cuando más falta hace poder salir, el enlace sigue yendo a + donde tiene que ir.""" + plantilla = self._lanzador() + self.assertIn('href="/web/session/logout"', plantilla) + + def test_la_ruta_de_salida_es_la_que_usa_odoo(self): + """Escrita a mano en la plantilla: si el core la cambiara, aquí se + ve antes que en el mostrador.""" + with file_open('web/static/src/webclient/user_menu/user_menu_items.js') as f: + nativo = f.read() + self.assertIn('/web/session/logout', nativo, + 'Odoo cambió su ruta de cierre de sesión')