El lanzador tiene por dónde cerrar sesión
This commit is contained in:
1 parent
7a51c4dc2a
commit
2ef4621a89
4 files changed
+100
-1
No files matched your search
@@ -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, {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -212,7 +212,29 @@
|
||||
</t>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
Cerrar sesión, al pie y a la izquierda de la firma.
|
||||
|
||||
Aquí y no en el menú de usuario de Odoo porque ese menú no
|
||||
es una puerta de este lanzador: quien opera desde una tablet
|
||||
de mostrador ve esta pantalla y nada más, y cerrar sesión es
|
||||
justo lo que hace al terminar su turno. Es un `<a>` con href
|
||||
real —no un botón con JavaScript— para que funcione igual si
|
||||
los assets fallan, que es cuando más falta hace poder salir.
|
||||
-->
|
||||
<div class="beyond_launcher_brand">
|
||||
<a class="beyond_launcher_salir" href="/web/session/logout"
|
||||
t-on-click="cerrarSesion">
|
||||
<svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||
<path d="M15 4h3a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-3"
|
||||
stroke="currentColor" stroke-width="2"
|
||||
stroke-linecap="round"/>
|
||||
<path d="M10 8l-4 4 4 4M6 12h9" stroke="currentColor"
|
||||
stroke-width="2" stroke-linecap="round"
|
||||
stroke-linejoin="round"/>
|
||||
</svg>
|
||||
<span>Cerrar sesión</span>
|
||||
</a>
|
||||
<span>Powered by Collina Systems</span>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
@@ -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 `<a href>` 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')
|
||||
Reference in new issue
Block a user