feat(fusion_clock): NFC kiosk page render route
Controller scaffold with GET /fusion_clock/kiosk/nfc, placeholder QWeb template, and HttpCase tests (10 pass, 0 failures). Fixed Odoo 19 res.users create API: groups_id -> group_ids. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -76,6 +76,7 @@ Integrates natively with Odoo's hr.attendance module for full payroll compatibil
|
|||||||
'views/portal_timesheet_templates.xml',
|
'views/portal_timesheet_templates.xml',
|
||||||
'views/portal_report_templates.xml',
|
'views/portal_report_templates.xml',
|
||||||
'views/kiosk_templates.xml',
|
'views/kiosk_templates.xml',
|
||||||
|
'views/kiosk_nfc_templates.xml',
|
||||||
],
|
],
|
||||||
'assets': {
|
'assets': {
|
||||||
'web.assets_frontend': [
|
'web.assets_frontend': [
|
||||||
|
|||||||
@@ -3,3 +3,4 @@
|
|||||||
from . import portal_clock
|
from . import portal_clock
|
||||||
from . import clock_api
|
from . import clock_api
|
||||||
from . import clock_kiosk
|
from . import clock_kiosk
|
||||||
|
from . import clock_nfc_kiosk
|
||||||
|
|||||||
36
fusion_clock/controllers/clock_nfc_kiosk.py
Normal file
36
fusion_clock/controllers/clock_nfc_kiosk.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2026 Nexa Systems Inc.
|
||||||
|
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from odoo import http
|
||||||
|
from odoo.http import request
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class FusionClockNfcKiosk(http.Controller):
|
||||||
|
"""NFC tap-to-clock kiosk controller. Reuses FusionClockAPI helpers."""
|
||||||
|
|
||||||
|
@http.route('/fusion_clock/kiosk/nfc', type='http', auth='user', website=True)
|
||||||
|
def nfc_kiosk_page(self, **kw):
|
||||||
|
"""Render the NFC kiosk page for a wall-mounted tablet."""
|
||||||
|
user = request.env.user
|
||||||
|
if not user.has_group('fusion_clock.group_fusion_clock_manager'):
|
||||||
|
return request.redirect('/my')
|
||||||
|
|
||||||
|
ICP = request.env['ir.config_parameter'].sudo()
|
||||||
|
if ICP.get_param('fusion_clock.enable_nfc_kiosk', 'False') != 'True':
|
||||||
|
return request.redirect('/my')
|
||||||
|
|
||||||
|
company = request.env.company
|
||||||
|
location = company.x_fclk_nfc_kiosk_location_id
|
||||||
|
values = {
|
||||||
|
'page_name': 'nfc_kiosk',
|
||||||
|
'company_name': company.name,
|
||||||
|
'location_name': location.name if location else 'No location configured',
|
||||||
|
'location_configured': bool(location),
|
||||||
|
'photo_required': ICP.get_param('fusion_clock.nfc_photo_required', 'True') == 'True',
|
||||||
|
'debug_enabled': ICP.get_param('fusion_clock.nfc_kiosk_debug', 'False') == 'True',
|
||||||
|
}
|
||||||
|
return request.render('fusion_clock.nfc_kiosk_page', values)
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from . import test_nfc_models
|
from . import test_nfc_models
|
||||||
|
from . import test_clock_nfc_kiosk
|
||||||
|
|||||||
38
fusion_clock/tests/test_clock_nfc_kiosk.py
Normal file
38
fusion_clock/tests/test_clock_nfc_kiosk.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from odoo.tests.common import HttpCase, tagged
|
||||||
|
|
||||||
|
|
||||||
|
@tagged('-at_install', 'post_install', 'fusion_clock')
|
||||||
|
class TestNfcKioskController(HttpCase):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super().setUpClass()
|
||||||
|
cls.ICP = cls.env['ir.config_parameter'].sudo()
|
||||||
|
cls.location = cls.env['fusion.clock.location'].create({
|
||||||
|
'name': 'Test Plant',
|
||||||
|
'latitude': 43.65,
|
||||||
|
'longitude': -79.38,
|
||||||
|
'radius': 100,
|
||||||
|
})
|
||||||
|
cls.env.company.x_fclk_nfc_kiosk_location_id = cls.location.id
|
||||||
|
cls.kiosk_user = cls.env['res.users'].create({
|
||||||
|
'name': 'NFC Kiosk User',
|
||||||
|
'login': 'nfc-kiosk-test',
|
||||||
|
'password': 'kioskpass123',
|
||||||
|
'group_ids': [(4, cls.env.ref('fusion_clock.group_fusion_clock_manager').id)],
|
||||||
|
})
|
||||||
|
|
||||||
|
def test_kiosk_page_redirects_when_disabled(self):
|
||||||
|
self.ICP.set_param('fusion_clock.enable_nfc_kiosk', 'False')
|
||||||
|
self.authenticate('nfc-kiosk-test', 'kioskpass123')
|
||||||
|
response = self.url_open('/fusion_clock/kiosk/nfc', allow_redirects=False)
|
||||||
|
self.assertIn(response.status_code, (301, 302, 303))
|
||||||
|
|
||||||
|
def test_kiosk_page_renders_when_enabled(self):
|
||||||
|
self.ICP.set_param('fusion_clock.enable_nfc_kiosk', 'True')
|
||||||
|
self.authenticate('nfc-kiosk-test', 'kioskpass123')
|
||||||
|
response = self.url_open('/fusion_clock/kiosk/nfc')
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
self.assertIn('NFC Clock Kiosk', response.text)
|
||||||
20
fusion_clock/views/kiosk_nfc_templates.xml
Normal file
20
fusion_clock/views/kiosk_nfc_templates.xml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<template id="nfc_kiosk_page" name="NFC Clock Kiosk">
|
||||||
|
<t t-call="web.frontend_layout">
|
||||||
|
<t t-set="no_header" t-value="True"/>
|
||||||
|
<t t-set="no_footer" t-value="True"/>
|
||||||
|
<div id="nfc_kiosk_root" class="nfc-kiosk">
|
||||||
|
<h1>NFC Clock Kiosk</h1>
|
||||||
|
<div t-if="not location_configured" class="alert alert-warning">
|
||||||
|
No NFC kiosk location configured for <t t-esc="company_name"/>. Ask your administrator to configure one in Fusion Clock settings.
|
||||||
|
</div>
|
||||||
|
<div t-else="">
|
||||||
|
<p>Clock at: <span t-esc="location_name"/></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user