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_control: Entry without exit. #63

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
30 changes: 30 additions & 0 deletions hr_attendance_control/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.. 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 control
=====================

* If, when an exit is registered, there is a difference of 20 hours between the
time of entry and the time of departure, the signing is closed with the
marked time, and another entry is created automatically with the same time of
the signing.

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.
3 changes: 3 additions & 0 deletions hr_attendance_control/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2019 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import models
17 changes: 17 additions & 0 deletions hr_attendance_control/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2019 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
{
"name": "Hr Attendance Control",
"version": "12.0.1.0.0",
"license": "AGPL-3",
"depends": [
"hr_attendance",
],
"author": "AvanzOSC",
"website": "http://www.avanzosc.es",
"category": "Human Resources",
"data": [
"views/hr_attendance_view.xml",
],
"installable": True,
}
33 changes: 33 additions & 0 deletions hr_attendance_control/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_attendance_control
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-05 16:39+0000\n"
"PO-Revision-Date: 2019-11-05 16:39+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: hr_attendance_control
#: model:ir.model,name:hr_attendance_control.model_hr_attendance
msgid "Attendance"
msgstr "Asistencia"

#. module: hr_attendance_control
#: model_terms:ir.ui.view,arch_db:hr_attendance_control.hr_attendance_view_filter
msgid "Entry with exit"
msgstr "Entrada con salida"

#. module: hr_attendance_control
#: model:ir.model.fields,field_description:hr_attendance_control.field_hr_attendance__entry_without_exit
#: model_terms:ir.ui.view,arch_db:hr_attendance_control.hr_attendance_view_filter
msgid "Entry without exit"
msgstr "Entrada sin salida"

33 changes: 33 additions & 0 deletions hr_attendance_control/i18n/hr_attendance_control.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_attendance_control
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-05 16:38+0000\n"
"PO-Revision-Date: 2019-11-05 16:38+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: hr_attendance_control
#: model:ir.model,name:hr_attendance_control.model_hr_attendance
msgid "Attendance"
msgstr ""

#. module: hr_attendance_control
#: model_terms:ir.ui.view,arch_db:hr_attendance_control.hr_attendance_view_filter
msgid "Entry with exit"
msgstr ""

#. module: hr_attendance_control
#: model:ir.model.fields,field_description:hr_attendance_control.field_hr_attendance__entry_without_exit
#: model_terms:ir.ui.view,arch_db:hr_attendance_control.hr_attendance_view_filter
msgid "Entry without exit"
msgstr ""

3 changes: 3 additions & 0 deletions hr_attendance_control/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2019 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import hr_attendance
41 changes: 41 additions & 0 deletions hr_attendance_control/models/hr_attendance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2019 Alfredo de la fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import models, fields, api


class HrAttendance(models.Model):
_inherit = 'hr.attendance'

entry_without_exit = fields.Boolean(
string='Entry without exit', compute='_compute_entry_without_exit',
store=True)

@api.depends('check_in', 'check_out')
def _compute_entry_without_exit(self):
for record in self:
entry = False
if record.check_out:
worked_hours = record._catch_worked_hours()
if worked_hours >= 20.0:
entry = True
record.entry_without_exit = entry

@api.multi
def write(self, vals):
result = super(HrAttendance, self).write(vals)
if 'check_out' in vals and vals.get('check_out', False):
for attendance in self:
if attendance.check_out:
worked_hours = attendance._catch_worked_hours()
if worked_hours >= 20.0:
vals = {'employee_id': attendance.employee_id.id,
'check_in': attendance.check_out,
'checkt_out': False}
self.create(vals)
return result

@api.multi
def _catch_worked_hours(self):
delta = self.check_out - self.check_in
worked_hours = delta.total_seconds() / 3600.0
return worked_hours
25 changes: 25 additions & 0 deletions hr_attendance_control/views/hr_attendance_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_attendance_tree" model="ir.ui.view">
<field name="model">hr.attendance</field>
<field name="inherit_id" ref="hr_attendance.view_attendance_tree" />
<field name="arch" type="xml">
<field name="check_out" position="after">
<field name="entry_without_exit" />
</field>
</field>
</record>
<record id="hr_attendance_view_filter" model="ir.ui.view">
<field name="model">hr.attendance</field>
<field name="inherit_id" ref="hr_attendance.hr_attendance_view_filter" />
<field name="arch" type="xml">
<filter name="employee" position="after">
<filter name="group-with-exit" string="Entry without exit" context="{'group_by':'entry_without_exit'}"/>
</filter>
<filter name="myattendances" position="after">
<filter string="Entry with exit" name="filter-with-exit" domain="[('entry_without_exit', '=', False)]"/>
<filter string="Entry without exit" name="filter-without-exit" domain="[('entry_without_exit', '=', True)]"/>
</filter>
</field>
</record>
</odoo>