fix(fusion_clock): Photo Verification is now a real master switch (was ignored)

The global enable_photo_verification toggle only fed the portal get_settings flag;
the actual writes ignored it — the NFC kiosk gated on nfc_photo_required and the
portal on location.require_photo, so photos were captured even with the toggle OFF.
Now it's the master: OFF => no photo captured/stored anywhere (NFC kiosk config +
tap, and portal check-in); ON => per-location / NFC settings apply. Test + help
text updated. Bump 3.16.0 -> 3.16.1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-05-31 12:02:42 -04:00
parent d6d6bbe161
commit 2ee01fd1f2
6 changed files with 76 additions and 8 deletions

View File

@@ -454,3 +454,63 @@ class TestCreateEmployeeEndpoint(HttpCase):
def test_create_invalid_name(self):
result = self._call({'name': 'X', 'enroll_password': '1234'})
self.assertEqual(result.get('error'), 'invalid_name')
@tagged('-at_install', 'post_install', 'fusion_clock')
class TestTapPhotoMasterSwitch(HttpCase):
"""The global Photo Verification toggle is the master switch: when OFF, the
NFC kiosk stores no photo even if the client sends one; when ON (with
nfc_photo_required), it does."""
PNG = ('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwC'
'AAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=')
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.ICP = cls.env['ir.config_parameter'].sudo()
cls.ICP.set_param('fusion_clock.enable_nfc_kiosk', 'True')
cls.ICP.set_param('fusion_clock.nfc_photo_required', 'True')
cls.location = cls.env['fusion.clock.location'].create({
'name': 'Photo Plant', 'latitude': 43.65, 'longitude': -79.38, 'radius': 100,
})
cls.env.company.x_fclk_nfc_kiosk_location_id = cls.location.id
cls.env['res.users'].create({
'name': 'Photo Kiosk User', 'login': 'nfc-kiosk-photo', 'password': 'kioskpass123',
'group_ids': [(4, cls.env.ref('fusion_clock.group_fusion_clock_manager').id)],
})
cls.bob = cls.env['hr.employee'].create({
'name': 'Bob P', 'x_fclk_enable_clock': True,
'x_fclk_nfc_card_uid': '04:A2:B5:62:C1:91',
})
def setUp(self):
super().setUp()
from odoo.addons.fusion_clock.controllers import clock_nfc_kiosk as nfc_kiosk_module
nfc_kiosk_module._recent_taps.clear()
def _tap(self):
self.authenticate('nfc-kiosk-photo', 'kioskpass123')
response = self.url_open(
'/fusion_clock/kiosk/nfc/tap',
data=json.dumps({'jsonrpc': '2.0', 'method': 'call',
'params': {'card_uid': '04:A2:B5:62:C1:91', 'photo_b64': self.PNG}}),
headers={'Content-Type': 'application/json'},
)
return response.json().get('result', {})
def _latest(self):
return self.env['hr.attendance'].search(
[('employee_id', '=', self.bob.id)], order='check_in desc', limit=1)
def test_no_photo_stored_when_master_off(self):
self.ICP.set_param('fusion_clock.enable_photo_verification', 'False')
result = self._tap()
self.assertTrue(result.get('success'))
self.assertFalse(self._latest().x_fclk_check_in_photo)
def test_photo_stored_when_master_on(self):
self.ICP.set_param('fusion_clock.enable_photo_verification', 'True')
result = self._tap()
self.assertTrue(result.get('success'))
self.assertTrue(self._latest().x_fclk_check_in_photo)