Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] hr_attendance_resume_anomaly: This module performs anomaly cont… #71

Open
wants to merge 1 commit into
base: 12.0
Choose a base branch
from
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
43 changes: 43 additions & 0 deletions hr_attendance_resume_anomaly/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

============================
Hr attendance resume anomaly
============================

* This module performs anomaly control in the attendances summary. These are
the anomalies that are controlled:

- "There are attendances in day that do not apply". No turn or has
vacationed.
- "Have absence". The worker has worked, and has absent.
- "Festive worked". The worker has worked on festive day.
- "There is an approved absence and there is no attendance". The worker has
not imputed, and is absent.
- "Entry without exit". The worker forgot to impute in at the exit.
- "Attendances very often". Imputations very often, less than 1 minute.
- "There is no attendance in day that corresponds". The worker should to have
imputed on this day, and has not done so.
- "Real working day greater or less than the percentage over the planned day"
Actual day greater or lesser than the percentage of expected day
(provided there are no approved absences). The percentages are defined in
the calendar, one for excess, and another defect.

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

Bugs are tracked on `GitHub Issues
<https://github.com/avanzosc/hr-addons/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

Credits
=======

Contributors
------------
* Ana Juaristi <[email protected]>
* Alfredo de la Fuente <[email protected]>

Do not contact contributors directly about support or help with technical issues.
4 changes: 4 additions & 0 deletions hr_attendance_resume_anomaly/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2019 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import models
from . import wizard
23 changes: 23 additions & 0 deletions hr_attendance_resume_anomaly/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2019 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
{
"name": "Hr Attendance Resume Anomaly",
"version": "12.0.1.0.0",
"license": "AGPL-3",
"depends": [
"hr_attendance_control",
"hr_attendance_resume_holidays",
"hr_attendance_resume_absences"
],
"author": "AvanzOSC",
"website": "http://www.avanzosc.es",
"category": "Human Resources",
"data": [
"security/ir.model.access.csv",
"data/hr_attendance_resume_anomaly_data.xml",
"wizard/wiz_attendance_resume_put_resolved_view.xml",
"views/hr_attendance_resume_view.xml",
"views/resource_calendar_view.xml",
],
"installable": True,
}
64 changes: 64 additions & 0 deletions hr_attendance_resume_anomaly/_common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright 2019 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from datetime import date as datetype
from dateutil.relativedelta import relativedelta
from pytz import timezone, utc
from odoo import fields, _

str2datetime = fields.Datetime.from_string
date2str = fields.Date.to_string


def _convert_to_local_date(date, tz=u'UTC'):
if not date:
return False
if not tz:
tz = u'UTC'
new_date = str2datetime(date) if isinstance(date, str) else date
new_date = new_date.replace(tzinfo=utc)
local_date = new_date.astimezone(timezone(tz)).replace(tzinfo=None)
return local_date


def _convert_to_utc_date(date, time=0.0, tz=u'UTC'):
if not date:
return False
if not tz:
tz = u'UTC'
date = date2str(date) if isinstance(date, datetype) else date
date = str2datetime(date) if isinstance(date, str) else date
date += relativedelta(hours=float(time))
local = timezone(tz)
local_date = local.localize(date, is_dst=None)
utc_date = local_date.astimezone(utc).replace(tzinfo=None)
return utc_date


def _convert_time_to_float(date, tz=u'UTC'):
if not date:
return False
if not tz:
tz = u'UTC'
local_time = _convert_to_local_date(date, tz=tz)
hour = float(local_time.hour)
minutes = float(local_time.minute) / 60
seconds = float(local_time.second) / 360
return (hour + minutes + seconds)


def _catch_dayofweek(date):
day = str(date.weekday())
if day == '0':
return _('Monday')
if day == '1':
return _('Tuesday')
if day == '2':
return _('Wednesday')
if day == '3':
return _('Thursday')
if day == '4':
return _('Friday')
if day == '5':
return _('Saturday')
if day == '6':
return _('Sunday')
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">
<record id="hr_attendance_anomaly_without_calendar_day" model="hr.attendance.resume.anomaly">
<field name="name">There are attendances in day that do not apply</field>
</record>
<record id="hr_attendance_anomaly_with_leave" model="hr.attendance.resume.anomaly">
<field name="name">Have absence</field>
</record>
<record id="hr_attendance_anomaly_festive_worked" model="hr.attendance.resume.anomaly">
<field name="name">Festive worked</field>
</record>
<record id="hr_attendance_anomaly_with_approved_absence" model="hr.attendance.resume.anomaly">
<field name="name">There is an approved absence and there is no attendance</field>
</record>
<record id="hr_attendance_anomaly_entry_without_exit" model="hr.attendance.resume.anomaly">
<field name="name">Entry without exit</field>
</record>
<record id="hr_attendance_anomaly_entry_very_often" model="hr.attendance.resume.anomaly">
<field name="name">Attendances very often</field>
</record>
<record id="hr_attendance_anomaly_entry_no_attendance" model="hr.attendance.resume.anomaly">
<field name="name">There is no attendance in day that corresponds</field>
</record>
<record id="hr_attendance_anomaly_entry_percentage_day" model="hr.attendance.resume.anomaly">
<field name="name">Real working day greater or less than the percentage over the planned day</field>
</record>
<record id="hr_attendance_anomaly_negative_time" model="hr.attendance.resume.anomaly">
<field name="name">Negative imputable time</field>
</record>
</odoo>
Loading