From a20b457fa748d730b518d870bfe5147fc88746c3 Mon Sep 17 00:00:00 2001 From: Thor Date: Wed, 6 Nov 2019 09:26:41 +0100 Subject: [PATCH] [ADD] hr_attendance_control: Entry without exit. --- hr_attendance_control/README.rst | 30 ++++++++++++++ hr_attendance_control/__init__.py | 3 ++ hr_attendance_control/__manifest__.py | 17 ++++++++ hr_attendance_control/i18n/es.po | 33 +++++++++++++++ .../i18n/hr_attendance_control.pot | 33 +++++++++++++++ hr_attendance_control/models/__init__.py | 3 ++ hr_attendance_control/models/hr_attendance.py | 41 +++++++++++++++++++ .../views/hr_attendance_view.xml | 25 +++++++++++ 8 files changed, 185 insertions(+) create mode 100644 hr_attendance_control/README.rst create mode 100644 hr_attendance_control/__init__.py create mode 100644 hr_attendance_control/__manifest__.py create mode 100644 hr_attendance_control/i18n/es.po create mode 100644 hr_attendance_control/i18n/hr_attendance_control.pot create mode 100644 hr_attendance_control/models/__init__.py create mode 100644 hr_attendance_control/models/hr_attendance.py create mode 100644 hr_attendance_control/views/hr_attendance_view.xml diff --git a/hr_attendance_control/README.rst b/hr_attendance_control/README.rst new file mode 100644 index 00000000..e103d206 --- /dev/null +++ b/hr_attendance_control/README.rst @@ -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 +`_. 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 +* Alfredo de la Fuente + +Do not contact contributors directly about support or help with technical issues. diff --git a/hr_attendance_control/__init__.py b/hr_attendance_control/__init__.py new file mode 100644 index 00000000..1fd704ff --- /dev/null +++ b/hr_attendance_control/__init__.py @@ -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 diff --git a/hr_attendance_control/__manifest__.py b/hr_attendance_control/__manifest__.py new file mode 100644 index 00000000..da20e2d1 --- /dev/null +++ b/hr_attendance_control/__manifest__.py @@ -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, +} diff --git a/hr_attendance_control/i18n/es.po b/hr_attendance_control/i18n/es.po new file mode 100644 index 00000000..657465b8 --- /dev/null +++ b/hr_attendance_control/i18n/es.po @@ -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" + diff --git a/hr_attendance_control/i18n/hr_attendance_control.pot b/hr_attendance_control/i18n/hr_attendance_control.pot new file mode 100644 index 00000000..33635437 --- /dev/null +++ b/hr_attendance_control/i18n/hr_attendance_control.pot @@ -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 "" + diff --git a/hr_attendance_control/models/__init__.py b/hr_attendance_control/models/__init__.py new file mode 100644 index 00000000..1b7aead5 --- /dev/null +++ b/hr_attendance_control/models/__init__.py @@ -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 diff --git a/hr_attendance_control/models/hr_attendance.py b/hr_attendance_control/models/hr_attendance.py new file mode 100644 index 00000000..ff9f7063 --- /dev/null +++ b/hr_attendance_control/models/hr_attendance.py @@ -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 diff --git a/hr_attendance_control/views/hr_attendance_view.xml b/hr_attendance_control/views/hr_attendance_view.xml new file mode 100644 index 00000000..e3242b92 --- /dev/null +++ b/hr_attendance_control/views/hr_attendance_view.xml @@ -0,0 +1,25 @@ + + + + hr.attendance + + + + + + + + + hr.attendance + + + + + + + + + + + +