-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] hr_attendance_control: Entry without exit.
- Loading branch information
1 parent
d27f18f
commit 895dce5
Showing
8 changed files
with
185 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,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. |
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,3 @@ | ||
# Copyright 2019 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from . import models |
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,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, | ||
} |
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,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" | ||
|
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,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 "" | ||
|
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,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 |
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,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 |
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,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> |