diff --git a/addons/beyond_attendance_qr/__manifest__.py b/addons/beyond_attendance_qr/__manifest__.py index 6f1b141..33645d8 100644 --- a/addons/beyond_attendance_qr/__manifest__.py +++ b/addons/beyond_attendance_qr/__manifest__.py @@ -37,6 +37,13 @@ calcada del sistema Taboada de Collina: 'views/portal_templates.xml', 'views/registro_templates.xml', ], + 'assets': { + 'web.assets_backend': [ + 'beyond_attendance_qr/static/src/kiosco_abrir/kiosco_abrir_dialog.scss', + 'beyond_attendance_qr/static/src/kiosco_abrir/kiosco_abrir_dialog.js', + 'beyond_attendance_qr/static/src/kiosco_abrir/kiosco_abrir_dialog.xml', + ], + }, 'demo': [], 'installable': True, 'application': False, diff --git a/addons/beyond_attendance_qr/controllers/kiosco.py b/addons/beyond_attendance_qr/controllers/kiosco.py index c32dba9..34bcf7c 100644 --- a/addons/beyond_attendance_qr/controllers/kiosco.py +++ b/addons/beyond_attendance_qr/controllers/kiosco.py @@ -23,12 +23,11 @@ class BeyondKioscoQR(BeyondKioskController): Token = request.env['beyond.checada.token'].sudo() estado = Token._emitir_para_kiosco(branch)._estado_kiosco() \ if Token._ventana_abierta() else Token.browse()._estado_kiosco() - # PIN de respaldo: el kiosco nativo de asistencias en la misma tablet - pin_url = branch.company_id.sudo().attendance_kiosk_url or '' + # PIN link removed by design decision (18-aug-2026); full PIN removal + # pending backend task — nothing else about the PIN is touched here. return request.render('beyond_attendance_qr.kiosco_page', { 'branch': branch, 'estado': estado, - 'pin_url': pin_url, }) @http.route('/beyond/kiosco//estado', type='http', diff --git a/addons/beyond_attendance_qr/models/beyond_kiosco_abrir.py b/addons/beyond_attendance_qr/models/beyond_kiosco_abrir.py index e089df7..c12e5ed 100644 --- a/addons/beyond_attendance_qr/models/beyond_kiosco_abrir.py +++ b/addons/beyond_attendance_qr/models/beyond_kiosco_abrir.py @@ -1,5 +1,5 @@ # Part of Beyond. Collina Systems proprietary module. -from odoo import _, api, fields, models +from odoo import _, api, models from odoo.exceptions import UserError @@ -12,14 +12,15 @@ class BeyondKioscoAbrir(models.TransientModel): Decisión documentada: el ADMIN GENERAL también lo ve, con selector de todas las sucursales — abre tiendas y hace demos, y el selector ya existe para el caso múltiple. + + Since the v2 redesign (18-aug-2026) the selector is an OWL dialog and + this model is its engine, not a form: it answers which branches the user + may see and turns a pick into the act_url. Branch isolation is decided + here by ir.rule on beyond.branch, never by the client. """ _name = 'beyond.kiosco.abrir' _description = 'Abrir kiosco de sucursal' - branch_id = fields.Many2one( - 'beyond.branch', string='Sucursal', required=True, - default=lambda self: self._branches_del_usuario()[:1]) - def _branches_del_usuario(self): if self.env.user.has_group('beyond_base.beyond_group_admin_general'): return self.env['beyond.branch'].search([]) @@ -35,17 +36,32 @@ class BeyondKioscoAbrir(models.TransientModel): 'general que te asigne la tuya.')) if len(branches) == 1: return self._act_url(branches) - return { - 'type': 'ir.actions.act_window', - 'name': _('Abrir kiosco'), - 'res_model': self._name, - 'view_mode': 'form', - 'target': 'new', - } + # Plain-function client action: the dialog owns its own chrome, which + # a form view in a modal cannot express (chips, live search, grid). + return {'type': 'ir.actions.client', 'tag': 'beyond_kiosco_abrir'} - def action_abrir(self): - self.ensure_one() - return self._act_url(self.branch_id) + @api.model + def sucursales_permitidas(self): + """Rows for the dialog's chips and search table. Read as the user, so + the branch ir.rule is what filters; no domain is trusted from JS.""" + branches = self._branches_del_usuario() + return [{ + 'id': branch.id, + 'code': branch.code or '', + 'name': branch.name or '', + 'street': branch.street or '', + 'city': branch.city or '', + } for branch in branches] + + @api.model + def abrir_sucursal(self, branch_id): + """Confirm from the dialog. The id is re-checked against the user's + own set: the client picks, the server decides.""" + branch = self._branches_del_usuario().filtered( + lambda b: b.id == branch_id) + if not branch: + raise UserError(_('Esa sucursal no está entre las tuyas.')) + return self._act_url(branch) @staticmethod def _act_url(branch): diff --git a/addons/beyond_attendance_qr/static/src/kiosco_abrir/kiosco_abrir_dialog.js b/addons/beyond_attendance_qr/static/src/kiosco_abrir/kiosco_abrir_dialog.js new file mode 100644 index 0000000..ce5094c --- /dev/null +++ b/addons/beyond_attendance_qr/static/src/kiosco_abrir/kiosco_abrir_dialog.js @@ -0,0 +1,130 @@ +/** Part of Beyond. Collina Systems proprietary module. */ +import { Component, onWillStart, useState } from "@odoo/owl"; +import { Dialog } from "@web/core/dialog/dialog"; +import { registry } from "@web/core/registry"; +import { useAutofocus, useService } from "@web/core/utils/hooks"; +import { _t } from "@web/core/l10n/translation"; + +// Past this many branches the chips stop being a glance and become a wall, +// so the rest move behind "Buscar más…". +const CHIP_LIMIT = 6; + +/** + * C-023 v2 selector. Rendered as an OWL dialog rather than a restyled form + * view: the design needs pill chips, a live-filtering search table and its own + * header/footer chrome, none of which a form view in a modal can express + * without fighting Odoo's modal styling at every step. + * + * The model stays the authority. This component never builds a domain and + * never trusts its own list: it asks which branches the user may see and sends + * back an id that the server re-checks. + */ +export class KioscoAbrirDialog extends Component { + static template = "beyond_attendance_qr.KioscoAbrirDialog"; + static components = { Dialog }; + static props = { close: Function }; + + setup() { + this.orm = useService("orm"); + this.action = useService("action"); + this.state = useState({ + branches: [], + selectedId: null, + screen: "pick", // "pick" | "search" + query: "", + }); + useAutofocus({ refName: "search" }); + onWillStart(async () => { + const branches = await this.orm.call( + "beyond.kiosco.abrir", + "sucursales_permitidas", + [] + ); + this.state.branches = branches; + this.state.selectedId = branches.length ? branches[0].id : null; + }); + } + + get title() { + return this.state.screen === "search" + ? _t("Buscar sucursal") + : _t("Abrir código QR"); + } + + /** + * The first few branches, plus the selected one when it came from the + * search and would otherwise be off the list — the design shows the pick + * reflected in a selected chip. + */ + get chips() { + const shown = this.state.branches.slice(0, CHIP_LIMIT); + const selected = this.selected; + if (selected && !shown.includes(selected)) { + shown.push(selected); + } + return shown; + } + + /** + * Decision (18-aug-2026): with everything already on screen the link is a + * dead end, so it is hidden rather than shown disabled. It only appears + * once there are branches the chips do not show. + */ + get showSearchLink() { + return this.state.branches.length > CHIP_LIMIT; + } + + get selected() { + return this.state.branches.find((b) => b.id === this.state.selectedId); + } + + get rows() { + const query = this.state.query.trim().toLowerCase(); + if (!query) { + return this.state.branches; + } + return this.state.branches.filter((b) => + `${b.code} ${b.name} ${b.street} ${b.city}`.toLowerCase().includes(query) + ); + } + + selectBranch(id) { + this.state.selectedId = id; + } + + openSearch() { + this.state.query = ""; + this.state.screen = "search"; + } + + closeSearch() { + this.state.screen = "pick"; + } + + pickRow(id) { + this.selectBranch(id); + this.closeSearch(); + } + + onQueryInput(ev) { + this.state.query = ev.target.value; + } + + async confirm() { + if (!this.state.selectedId) { + return; + } + const action = await this.orm.call("beyond.kiosco.abrir", "abrir_sucursal", [ + this.state.selectedId, + ]); + this.props.close(); + await this.action.doAction(action); + } +} + +// Registered as a plain function, not a Component: the action service then +// just calls it (action_service._executeClientAction), so the dialog owns its +// chrome instead of being wrapped in an action controller. +registry.category("actions").add("beyond_kiosco_abrir", (env) => { + env.services.dialog.add(KioscoAbrirDialog); +}); diff --git a/addons/beyond_attendance_qr/static/src/kiosco_abrir/kiosco_abrir_dialog.scss b/addons/beyond_attendance_qr/static/src/kiosco_abrir/kiosco_abrir_dialog.scss new file mode 100644 index 0000000..1e5c96b --- /dev/null +++ b/addons/beyond_attendance_qr/static/src/kiosco_abrir/kiosco_abrir_dialog.scss @@ -0,0 +1,301 @@ +// ============================================================================= +// C-023 v2 · "Abrir código QR" dialog and its branch search. +// +// Faithful to the signed-off design; every colour comes from a token in +// beyond_base/static/src/scss/beyond_variables.scss, never a loose hex. Two +// deliberate departures, both marked TOUCH below: the design sizes some +// controls under the 48px floor this project holds itself to. +// +// The rules are scoped by .beyond_qr_dialog (the Dialog's contentClass) so +// nothing here leaks into other Odoo dialogs. +// ============================================================================= + +$beyond-qr-font: Manrope, ui-sans-serif, system-ui, sans-serif; + +.o_dialog:has(.beyond_qr_dialog) { + // The design's own veil. Scoped to this dialog: .modal-backdrop is shared + // by every dialog in the web client and must not be recoloured. + > .modal { + background-color: rgba(35, 32, 29, 0.45); + } + + .modal-dialog { + max-width: 560px; + width: 100%; + } + + // Search screen is the wider panel. + .modal-dialog:has(.beyond_qr_dialog_wide) { + max-width: 680px; + } +} + +.beyond_qr_dialog { + font-family: $beyond-qr-font; + background: $beyond-surface; + border: 0; + border-radius: 28px; + box-shadow: 0 24px 60px rgba(20, 17, 14, 0.35); + // The panel is one flex column; header, body and footer are its children, + // so the design's single gap governs the whole dialog. + display: flex; + flex-direction: column; + gap: 22px; + padding: 28px 32px 32px; + + &.beyond_qr_dialog_wide { + gap: 20px; + } + + // Strip Bootstrap's chrome: the panel above already draws it. + .modal-header, + .modal-body, + .modal-footer { + background: transparent; + border: 0; + padding: 0; + margin: 0; + } + + .modal-header { + display: flex; + align-items: center; + justify-content: space-between; + } + + .modal-footer { + display: flex; + justify-content: flex-start; + gap: 10px; + padding-top: 2px; + } + + // ------------------------------------------------------------------------- + // Header + // ------------------------------------------------------------------------- + .beyond_qr_title { + font-size: 24px; + font-weight: 800; + letter-spacing: -0.02em; + color: $beyond-ink; + } + + .beyond_qr_close { + all: unset; + box-sizing: border-box; + cursor: pointer; + // TOUCH — the design sizes this at 40px, below the 48px floor. Left as + // designed: growing it visibly breaks the header composition, and the + // control is redundant (Escape and "Cancelar" both close the dialog). + width: 40px; + height: 40px; + border-radius: 14px; + display: flex; + align-items: center; + justify-content: center; + + &:hover { background: $beyond-surface-hover; } + &:focus-visible { outline: 4px solid $beyond-ink; } + } + + // ------------------------------------------------------------------------- + // Body + // ------------------------------------------------------------------------- + .beyond_qr_body { + display: flex; + flex-direction: column; + gap: 22px; + } + + &.beyond_qr_dialog_wide .beyond_qr_body { + gap: 20px; + } + + .beyond_qr_field { + display: flex; + flex-direction: column; + gap: 10px; + } + + .beyond_qr_label { + font-size: 12px; + font-weight: 800; + letter-spacing: 0.08em; + text-transform: uppercase; + color: $beyond-ink-muted; + } + + .beyond_qr_chips { + display: flex; + align-items: center; + gap: 8px; + flex-wrap: wrap; + } + + .beyond_qr_chip { + all: unset; + box-sizing: border-box; + cursor: pointer; + padding: 12px 22px; + // TOUCH — the design's padding lands at ~42px; this raises the pill to + // the 48px floor without changing padding, type or colour. + min-height: 48px; + display: flex; + align-items: center; + border-radius: 999px; + font-size: 15px; + font-weight: 700; + background: $beyond-surface-hover; + color: $beyond-ink-soft; + transition: background 140ms ease; + + &.selected { + background: $beyond-kiosco; + color: #FFFFFF; + } + + &:focus-visible { outline: 4px solid $beyond-ink; } + } + + .beyond_qr_more { + all: unset; + cursor: pointer; + margin-left: 8px; + font-size: 14px; + font-weight: 700; + color: $beyond-kiosco; + + &:hover { color: $beyond-kiosco-darker; } + &:focus-visible { outline: 4px solid $beyond-ink; } + } + + .beyond_qr_help { + font-size: 15px; + line-height: 1.55; + color: $beyond-ink-softer; + } + + // ------------------------------------------------------------------------- + // Search screen + // ------------------------------------------------------------------------- + .beyond_qr_search { + display: flex; + align-items: center; + gap: 10px; + background: $beyond-surface-hover; + border-radius: 999px; + padding: 12px 18px; + + input { + all: unset; + flex: 1; + min-width: 0; + font-size: 15px; + font-weight: 600; + color: $beyond-ink; + + &::placeholder { color: $beyond-ink-muted; } + } + } + + .beyond_qr_table { + display: flex; + flex-direction: column; + gap: 6px; + } + + .beyond_qr_head, + .beyond_qr_row { + display: grid; + grid-template-columns: 64px 1.2fr 1.4fr 1fr; + gap: 12px; + align-items: center; + } + + .beyond_qr_head { + padding: 0 18px; + font-size: 11px; + font-weight: 800; + letter-spacing: 0.08em; + text-transform: uppercase; + color: $beyond-ink-muted; + } + + .beyond_qr_row { + all: unset; + box-sizing: border-box; + cursor: pointer; + display: grid; + grid-template-columns: 64px 1.2fr 1.4fr 1fr; + gap: 12px; + align-items: center; + padding: 14px 18px; + border-radius: 18px; + text-align: left; + transition: background 140ms ease; + + &:hover, + &:focus { background: $beyond-surface-hover; } + // The design marks focus with the same tint as hover, which a keyboard + // user cannot tell apart from the row under the pointer. The ring is + // added on top, using the launcher's focus value. + &:focus-visible { outline: 4px solid $beyond-ink; } + } + + .beyond_qr_code { + font-size: 13px; + font-weight: 700; + color: $beyond-ink-muted; + } + + .beyond_qr_name { + font-size: 15px; + font-weight: 800; + color: $beyond-ink; + } + + .beyond_qr_cell { + font-size: 14px; + color: $beyond-ink-softer; + } + + .beyond_qr_empty { + padding: 18px; + font-size: 14px; + color: $beyond-ink-muted; + } + + // ------------------------------------------------------------------------- + // Actions + // ------------------------------------------------------------------------- + .beyond_qr_btn { + all: unset; + box-sizing: border-box; + cursor: pointer; + padding: 14px 28px; + min-height: 48px; // TOUCH — the design already lands here. + display: flex; + align-items: center; + border-radius: 999px; + font-size: 16px; + font-weight: 800; + transition: background 140ms ease; + + &:focus-visible { outline: 4px solid $beyond-ink; } + } + + .beyond_qr_btn_primary { + background: $beyond-kiosco; + color: #FFFFFF; + + &:hover { background: $beyond-kiosco-dark; } + &:active { background: $beyond-kiosco-darker; } + } + + .beyond_qr_btn_ghost { + background: $beyond-surface-hover; + color: $beyond-ink; + + &:hover { background: $beyond-surface-active; } + } +} diff --git a/addons/beyond_attendance_qr/static/src/kiosco_abrir/kiosco_abrir_dialog.xml b/addons/beyond_attendance_qr/static/src/kiosco_abrir/kiosco_abrir_dialog.xml new file mode 100644 index 0000000..435bd04 --- /dev/null +++ b/addons/beyond_attendance_qr/static/src/kiosco_abrir/kiosco_abrir_dialog.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + +
+
+ Sucursal +
+ +
+
+ El kiosco se abre en una pestaña nueva, + listo para dejarse a pantalla completa en la tablet de la + sucursal. +
+ + +
+ +
+
+ CódigoNombreDirecciónCiudad +
+ + Sin resultados + para tu búsqueda. +
+
+ + + + + + + + +
+
+
diff --git a/addons/beyond_attendance_qr/tests/test_kiosco_abrir.py b/addons/beyond_attendance_qr/tests/test_kiosco_abrir.py index 832208b..0ab6ec0 100644 --- a/addons/beyond_attendance_qr/tests/test_kiosco_abrir.py +++ b/addons/beyond_attendance_qr/tests/test_kiosco_abrir.py @@ -21,20 +21,41 @@ class TestBeyondKioscoAbrir(BeyondChecadorCase): "pestaña nueva: el kiosco es fullscreen y se queda en la tablet") def test_varias_sucursales_muestran_selector(self): + """El selector v2 es un diálogo OWL: la acción de servidor devuelve + la acción de cliente y el diálogo llama de vuelta al modelo.""" accion = self._abrir(self.admin_ab) - self.assertEqual(accion['type'], 'ir.actions.act_window') - self.assertEqual(accion['res_model'], 'beyond.kiosco.abrir') - wizard = self.env['beyond.kiosco.abrir'].with_user(self.admin_ab).create({ - 'branch_id': self.branch_b.id}) - resultado = wizard.action_abrir() + self.assertEqual(accion['type'], 'ir.actions.client') + self.assertEqual(accion['tag'], 'beyond_kiosco_abrir') + resultado = self.env['beyond.kiosco.abrir'].with_user( + self.admin_ab).abrir_sucursal(self.branch_b.id) self.assertEqual(resultado['url'], self.branch_b.kiosk_url) self.assertEqual(resultado['target'], 'new') + def test_sucursales_del_dialogo_respetan_el_aislamiento(self): + filas = self.env['beyond.kiosco.abrir'].with_user( + self.admin_ab).sucursales_permitidas() + self.assertEqual({f['id'] for f in filas}, + set((self.branch_a | self.branch_b).ids)) + self.assertEqual( + {f['name'] for f in filas}, + {self.branch_a.name, self.branch_b.name}) + # las columnas del buscador vienen de campos reales de beyond.branch + for fila in filas: + self.assertEqual(set(fila), + {'id', 'code', 'name', 'street', 'city'}) + + def test_abrir_sucursal_ajena_rebota(self): + """El diálogo elige, el servidor decide: un id fuera de las + sucursales del usuario no abre nada.""" + with self.assertRaises(UserError): + self.env['beyond.kiosco.abrir'].with_user( + self.admin_a).abrir_sucursal(self.branch_b.id) + def test_admin_general_selector_de_todas(self): """Decisión documentada: el admin general SÍ lo ve, con selector de todas las sucursales (abre tiendas y hace demos).""" accion = self._abrir(self.admin_general) - self.assertEqual(accion['type'], 'ir.actions.act_window') + self.assertEqual(accion['type'], 'ir.actions.client') branches = self.env['beyond.kiosco.abrir'].with_user( self.admin_general)._branches_del_usuario() self.assertEqual(set(branches.ids), diff --git a/addons/beyond_attendance_qr/views/kiosco_abrir_views.xml b/addons/beyond_attendance_qr/views/kiosco_abrir_views.xml index cb51f7a..acb5e5b 100644 --- a/addons/beyond_attendance_qr/views/kiosco_abrir_views.xml +++ b/addons/beyond_attendance_qr/views/kiosco_abrir_views.xml @@ -2,28 +2,11 @@ - - beyond.kiosco.abrir.form - beyond.kiosco.abrir - -
- - - -
- El kiosco se abre en una pestaña nueva, listo para dejarse - a pantalla completa en la tablet de la sucursal. -
-
-
-
-
-
+ como admin general) abre el diálogo "Abrir código QR". + The v2 selector is an OWL dialog (static/src/kiosco_abrir), so there + is no form view here any more: the server action returns an + ir.actions.client and the dialog calls back into the model. --> Kiosco diff --git a/addons/beyond_attendance_qr/views/kiosco_templates.xml b/addons/beyond_attendance_qr/views/kiosco_templates.xml index f1dbac3..cb87716 100644 --- a/addons/beyond_attendance_qr/views/kiosco_templates.xml +++ b/addons/beyond_attendance_qr/views/kiosco_templates.xml @@ -1,9 +1,20 @@ - +