Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions hr_attendance_geolocation_required/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
==================================
HR Attendance Geolocation Required
==================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:285cde1809d6a0e795995bc08585c6aafb7aa6eaeabe4f7445ee0e255559e922
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr--attendance-lightgray.png?logo=github
:target: https://github.com/OCA/hr-attendance/tree/17.0/hr_attendance_geolocation_required
:alt: OCA/hr-attendance
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/hr-attendance-17-0/hr-attendance-17-0-hr_attendance_geolocation_required
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/hr-attendance&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module enforces mandatory geolocation for employee attendance in
Odoo 17. Without this module, employees can clock in and out without
providing location data. With this module, employees must enable
location services in their browser and have GPS active on their device
before they can check in or out.

**Table of contents**

.. contents::
:local:

Usage
=====

1. Ensure that geolocation services are enabled on the employee’s
device.
2. Open *Attendances > Manage Attendances > Kiosk Mode*.
3. Employees attempting to check in or out must allow location access in
their browser.
4. If location access is denied, a notification appears instructing the
user to enable geolocation.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/hr-attendance/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/hr-attendance/issues/new?body=module:%20hr_attendance_geolocation_required%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Grupo Isonor

Contributors
------------

- [Grupo Isonor](https://www.grupoisonor.es):

- Álvaro Alonso Bada

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/hr-attendance <https://github.com/OCA/hr-attendance/tree/17.0/hr_attendance_geolocation_required>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions hr_attendance_geolocation_required/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2025 Álvaro Alonso Bada - Grupo Isonor
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from . import controllers
23 changes: 23 additions & 0 deletions hr_attendance_geolocation_required/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2025 Álvaro Alonso Bada - Grupo Isonor
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

{
"name": "HR Attendance Geolocation Required",
"summary": "Hace obligatoria la geolocalización para fichar en Odoo 17",
"author": "Odoo Community Association (OCA),Grupo Isonor",
"website": "https://github.com/OCA/hr-attendance",
"license": "LGPL-3",
"category": "hr_attendance",
"version": "17.0.1.0.0",
"depends": ["hr_attendance"],
"data": [],
"demo": [],
"assets": {
"web.assets_backend": [
"hr_attendance_geolocation_required/static/src/public_kiosk/public_kiosk_app.js",
],
},
"installable": True,
"application": False,
"auto_install": False,
}
4 changes: 4 additions & 0 deletions hr_attendance_geolocation_required/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2025 Álvaro Alonso Bada - Grupo Isonor
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from . import main
19 changes: 19 additions & 0 deletions hr_attendance_geolocation_required/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2025 Álvaro Alonso Bada - Grupo Isonor
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from odoo import http

from odoo.addons.hr_attendance.controllers.main import HrAttendance


class HrAttendanceCustom(HrAttendance):
@http.route()
def manual_selection_with_geolocation(
self, token, employee_id, pin_code, latitude=False, longitude=False
):
if not latitude or not longitude:
return {"error": "You must activate location and GPS to clock in."}

return super().manual_selection_with_geolocation(
token, employee_id, pin_code, latitude=latitude, longitude=longitude
)
3 changes: 3 additions & 0 deletions hr_attendance_geolocation_required/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions hr_attendance_geolocation_required/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- \[Grupo Isonor\](<https://www.grupoisonor.es>):
- Álvaro Alonso Bada
5 changes: 5 additions & 0 deletions hr_attendance_geolocation_required/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This module enforces mandatory geolocation for employee attendance in
Odoo 17. Without this module, employees can clock in and out without
providing location data. With this module, employees must enable
location services in their browser and have GPS active on their device
before they can check in or out.
7 changes: 7 additions & 0 deletions hr_attendance_geolocation_required/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1. Ensure that geolocation services are enabled on the employee’s
device.
2. Open *Attendances \> Manage Attendances \> Kiosk Mode*.
3. Employees attempting to check in or out must allow location access
in their browser.
4. If location access is denied, a notification appears instructing the
user to enable geolocation.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions hr_attendance_geolocation_required/static/description/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>HR Attendance Geolocation Required</title>
<style type="text/css">
body { font-family: Arial, sans-serif; line-height: 1.6; }
h1.title, h2.subtitle { text-align: center; }
.container { max-width: 800px; margin: auto; }
.badge img { margin-right: 10px; }
</style>
</head>
<body>
<div class="container" id="hr-attendance-geolocation-required">
<h1 class="title">HR Attendance Geolocation Required</h1>

<p>
<a href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a>
<a href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a>
<a href="https://github.com/OCA/hr-attendance/tree/17.0/hr_attendance_geolocation_required"><img alt="OCA/hr-attendance" src="https://img.shields.io/badge/github-OCA%2Fhr--attendance-lightgray.png?logo=github" /></a>
<a href="https://translation.odoo-community.org/projects/hr-attendance-17-0/hr-attendance-17-0-hr_attendance_geolocation_required"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a>
<a href="https://runboat.odoo-community.org/builds?repo=OCA/hr-attendance&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a>
</p>

<p>This module ensures that employees cannot check in or out unless their device has geolocation enabled.</p>

<h2>Table of contents</h2>
<ul>
<li><a href="#usage">Usage</a></li>
<li><a href="#bug-tracker">Bug Tracker</a></li>
<li><a href="#credits">Credits</a>
<ul>
<li><a href="#contributors">Contributors</a></li>
<li><a href="#maintainers">Maintainers</a></li>
</ul>
</li>
</ul>

<h2 id="usage">Usage</h2>
<ol>
<li>Go to <em>Attendances &gt; Configuration &gt; Configuration</em>.</li>
<li>Ensure that geolocation is required for attendance tracking.</li>
<li>Employees must allow GPS and browser location permissions to check in or out.</li>
<li>If location is not enabled, the system will prevent attendance and show an error message.</li>
</ol>

<h2 id="bug-tracker">Bug Tracker</h2>
<p>Bugs are tracked on <a href="https://github.com/OCA/hr-attendance/issues">GitHub Issues</a>.
If you encounter any problems, please check if your issue has already been reported.
If not, help us improve the module by providing detailed feedback <a href="https://github.com/OCA/hr-attendance/issues/new?body=module:%20hr_attendance_geolocation_required%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">here</a>.</p>

<h2 id="credits">Credits</h2>
<h3 id="contributors">Contributors</h3>
<ul>
<li>Álvaro Alonso &lt;[email protected]&gt;</li>
<li>Grupo Isonor</li>
<li>Odoo Community</li>
</ul>

<h3 id="maintainers">Maintainers</h3>
<p>This module is maintained by the OCA.</p>
<a href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.</p>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/** @odoo-module **/

import {_t} from "@web/core/l10n/translation";
import {patch} from "@web/core/utils/patch";

import PublicKiosk from "@hr_attendance/public_kiosk/public_kiosk_app";

class NoGeolocationError extends Error {}

patch(PublicKiosk.kioskAttendanceApp.prototype, {
async makeRpcWithGeolocation(route, params) {
const result = await super.makeRpcWithGeolocation(route, params);
if (result.error) {
this.displayNotification(_t("Error: %s", result.error));
throw new NoGeolocationError();
}
return result;
},

async onManualSelection(employeeId, enteredPin) {
try {
await super.onManualSelection(employeeId, enteredPin);
} catch (err) {
if (!(err instanceof NoGeolocationError)) {
throw err;
}
}
},
});
Loading