-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
3,025 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
==================== | ||
HR Attendance Reason | ||
==================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:1efc21ca72875c847f215f0527a36c5bf1bef11334f475fa794486791eea004f | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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_reason | ||
: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_reason | ||
: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 allows to define reasons why the attendance is not what | ||
expected. Some example reasons are | ||
|
||
- Could not access the system: Visit a customer | ||
- Leave soon to pick up children | ||
- The Hr manager amended the attendance and needs to tell | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
1. Go to *Attendances > Configuration*. | ||
2. Create the reasons that may cause attendances to be shorter or longer | ||
than normal | ||
3. When that situation occurs employees can justify the reason | ||
|
||
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_reason%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 | ||
------- | ||
|
||
* Odoo S.A. | ||
* Tecnativa | ||
|
||
Contributors | ||
------------ | ||
|
||
- Odoo S.A. | ||
- Aaron Henriquez <[email protected]> | ||
- Damien Crier <[email protected]> | ||
- Saran Lim. <[email protected]> | ||
- David Alonso <[email protected]> | ||
- Juany Davila <[email protected]> | ||
- `Tecnativa <https://www.tecnativa.com>`__: | ||
|
||
- Víctor Martínez | ||
- Carlos Lopez | ||
|
||
- Dhara Solanki <[email protected]> | ||
- `manaTec <https://www.manatec.de/>`__: | ||
|
||
- Tom Tietze | ||
|
||
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_reason>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from . import controllers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2017 Odoo S.A. | ||
# Copyright 2018 ForgeFlow, S.L. | ||
# License LGPL-3 - See http://www.gnu.org/licenses/lgpl-3.0.html | ||
|
||
{ | ||
"name": "HR Attendance Reason", | ||
"version": "18.0.1.0.0", | ||
"category": "Human Resources", | ||
"website": "https://github.com/OCA/hr-attendance", | ||
"author": "Odoo S.A., Tecnativa, Odoo Community Association (OCA)", | ||
"license": "LGPL-3", | ||
"installable": True, | ||
"depends": ["hr_attendance"], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"security/security.xml", | ||
"views/hr_attendance_reason_view.xml", | ||
"views/hr_attendance_view.xml", | ||
"views/res_config_settings_view.xml", | ||
], | ||
"demo": [ | ||
"demo/hr_attendance_reason_demo.xml", | ||
], | ||
"assets": { | ||
"web.assets_backend": [ | ||
"hr_attendance_reason/static/src/**/*", | ||
], | ||
"hr_attendance.assets_public_attendance": [ | ||
"hr_attendance_reason/static/src/**/*", | ||
], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# Copyright 2024 Tecnativa - Carlos Lopez | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import http | ||
from odoo.http import request, route | ||
|
||
from odoo.addons.hr_attendance.controllers.main import HrAttendance | ||
|
||
|
||
class HrAttendance(HrAttendance): | ||
# inherited routes | ||
@route("/hr_attendance/attendance_user_data", type="json", auth="user") | ||
def user_attendance_data(self): | ||
response = super().user_attendance_data() | ||
# try to get the company of the employee to show the correct reasons from | ||
# the employees company | ||
company = ( | ||
request.env.user.employee_id.company_id | ||
if request.env.user.employee_id | ||
else request.env.company | ||
) | ||
response.update(self._get_attendance_reason_settings(company)) | ||
# get available reasons for employee company | ||
reasons = [] | ||
if response.get("attendance_state", False): | ||
if response.get("attendance_state", False) == "checked_out": | ||
action_type = "sign_in" | ||
else: | ||
action_type = "sign_out" | ||
reasons = self._get_attendance_reasons(action_type, company) | ||
response.update({"reasons": reasons}) | ||
return response | ||
|
||
@route("/hr_attendance/systray_check_in_out", type="json", auth="user") | ||
def systray_attendance(self, latitude=False, longitude=False): | ||
if request.params.get("attendance_reason_id"): | ||
request.update_context( | ||
attendance_reason_id=request.params.get("attendance_reason_id") | ||
) | ||
return super().systray_attendance(latitude=latitude, longitude=longitude) | ||
|
||
@http.route("/hr_attendance/manual_selection", type="json", auth="public") | ||
def manual_selection_with_geolocation( | ||
self, token, employee_id, pin_code, latitude=False, longitude=False | ||
): | ||
if request.params.get("attendance_reason_id"): | ||
request.update_context( | ||
attendance_reason_id=request.params.get("attendance_reason_id") | ||
) | ||
return super().manual_selection_with_geolocation( | ||
token, employee_id, pin_code, latitude, longitude | ||
) | ||
|
||
# new routes | ||
@route("/hr_attendance_reason/get_reasons", type="json", auth="public") | ||
def attendance_get_reasons(self, token, employee_id, pin_code): | ||
company = self._get_company(token) | ||
if company: | ||
employee = request.env["hr.employee"].sudo().browse(employee_id) | ||
if employee.company_id == company and ( | ||
(not company.attendance_kiosk_use_pin) or (employee.pin == pin_code) | ||
): | ||
res = self._get_employee_info_response(employee) | ||
action_type = ( | ||
"sign_out" | ||
if res.get("attendance_state") == "checked_in" | ||
else "sign_in" | ||
) | ||
res.update( | ||
{ | ||
"reasons": self._get_attendance_reasons(action_type, company), | ||
**self._get_attendance_reason_settings(company), | ||
} | ||
) | ||
return res | ||
return {} | ||
|
||
@route("/hr_attendance_reason/reason_settings", type="json", auth="public") | ||
def kiosk_reason_settings(self, token): | ||
company = self._get_company(token) | ||
if company: | ||
return self._get_attendance_reason_settings(company) | ||
return {} | ||
|
||
def _get_attendance_reason_settings(self, company): | ||
show_reason = company.show_reason_on_attendance_screen | ||
required_reason = company.required_reason_on_attendance_screen | ||
default_sign_in_reason_id = ( | ||
company.reason_on_attendance_screen_default_sign_in.id | ||
) | ||
default_sign_out_reason_id = ( | ||
company.reason_on_attendance_screen_default_sign_out.id | ||
) | ||
return { | ||
"show_reason_on_attendance_screen": show_reason, | ||
"required_reason_on_attendance_screen": required_reason, | ||
"default_sign_in_reason_id": default_sign_in_reason_id, | ||
"default_sign_out_reason_id": default_sign_out_reason_id, | ||
} | ||
|
||
def _get_attendance_reasons(self, action_type, company): | ||
""" | ||
Get the attendance reasons to show on the attendance screen. | ||
:param action_type: sign_in or sign_out. | ||
""" | ||
AttendanceReason = request.env["hr.attendance.reason"].sudo() | ||
return AttendanceReason.search_read( | ||
domain=[ | ||
("show_on_attendance_screen", "=", True), | ||
("action_type", "=", action_type), | ||
("company_id", "in", [False, company.id]), | ||
], | ||
fields=["name", "action_type"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo noupdate="1"> | ||
<record id="hr_act_reason_1" model="hr.attendance.reason"> | ||
<field name="name">Manager Manual Amend</field> | ||
<field name="code">MMA</field> | ||
</record> | ||
<record id="hr_act_reason_2" model="hr.attendance.reason"> | ||
<field name="name">Felt Sick</field> | ||
<field name="code">FS</field> | ||
<field name="action_type">sign_out</field> | ||
<field name="show_on_attendance_screen" eval="True" /> | ||
</record> | ||
<record id="hr_act_reason_3" model="hr.attendance.reason"> | ||
<field name="name">Visit Customer</field> | ||
<field name="code">VS</field> | ||
<field name="action_type">sign_in</field> | ||
<field name="show_on_attendance_screen" eval="True" /> | ||
</record> | ||
<record id="hr_act_reason_4" model="hr.attendance.reason"> | ||
<field name="name">Bad Weather</field> | ||
<field name="code">BW</field> | ||
</record> | ||
<record id="hr_act_reason_5" model="hr.attendance.reason"> | ||
<field name="name">Public Transport Strike</field> | ||
<field name="code">PTS</field> | ||
<field name="action_type">sign_in</field> | ||
<field name="show_on_attendance_screen" eval="True" /> | ||
</record> | ||
</odoo> |
Oops, something went wrong.