From b5bc12fe928fce31fe310a8d5b5df06c570c62bc Mon Sep 17 00:00:00 2001 From: hveficent Date: Thu, 2 Aug 2018 11:42:55 +0200 Subject: [PATCH] [MIG] hr_attendance_rfid: Migration to 11.0 --- hr_attendance_rfid/README.rst | 66 ++- hr_attendance_rfid/__init__.py | 1 - hr_attendance_rfid/__manifest__.py | 5 +- hr_attendance_rfid/models/__init__.py | 1 - hr_attendance_rfid/models/hr_employee.py | 8 +- hr_attendance_rfid/readme/CONFIGURE.rst | 12 + hr_attendance_rfid/readme/CONTRIBUTORS.rst | 3 + hr_attendance_rfid/readme/DESCRIPTION.rst | 3 + hr_attendance_rfid/readme/USAGE.rst | 7 + .../security/hr_attendance_rfid.xml | 12 +- .../static/description/index.html | 429 ++++++++++++++++++ hr_attendance_rfid/tests/__init__.py | 1 - .../tests/test_hr_attendance_rfid_process.py | 19 +- 13 files changed, 531 insertions(+), 36 deletions(-) create mode 100644 hr_attendance_rfid/readme/CONFIGURE.rst create mode 100644 hr_attendance_rfid/readme/CONTRIBUTORS.rst create mode 100644 hr_attendance_rfid/readme/DESCRIPTION.rst create mode 100644 hr_attendance_rfid/readme/USAGE.rst create mode 100644 hr_attendance_rfid/static/description/index.html diff --git a/hr_attendance_rfid/README.rst b/hr_attendance_rfid/README.rst index 78b8a19ea0a1..64c24eebd62c 100644 --- a/hr_attendance_rfid/README.rst +++ b/hr_attendance_rfid/README.rst @@ -1,15 +1,39 @@ -.. 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 RFID ================== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr-lightgray.png?logo=github + :target: https://github.com/OCA/hr/tree/11.0/hr_attendance_rfid + :alt: OCA/hr +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/hr-11-0/hr-11-0-hr_attendance_rfid + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/116/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + This module extends the functionality of HR Attendance in order to allow the logging of employee attendances using an RFID based employee attendance system. +**Table of contents** + +.. contents:: + :local: + Configuration ============= @@ -37,37 +61,45 @@ Usage attendance system. It is expected that the system will provide some form of output of the registration event. - 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. +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= +Authors +~~~~~~~ + +* Comunitea +* Eficent + Contributors ------------- +~~~~~~~~~~~~ * Omar Catiñeira Saavedra * Héctor Villarreal Ortega * Jordi Ballester Alomar +Maintainers +~~~~~~~~~~~ -Maintainer ----------- +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png - :alt: Odoo Community Association - :target: https://odoo-community.org - -This module is maintained by the OCA. + :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. -To contribute to this module, please visit https://odoo-community.org. +This module is part of the `OCA/hr `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/hr_attendance_rfid/__init__.py b/hr_attendance_rfid/__init__.py index a0fdc10fe11b..0650744f6bc6 100644 --- a/hr_attendance_rfid/__init__.py +++ b/hr_attendance_rfid/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- from . import models diff --git a/hr_attendance_rfid/__manifest__.py b/hr_attendance_rfid/__manifest__.py index 88d6b1328172..23434adc220b 100644 --- a/hr_attendance_rfid/__manifest__.py +++ b/hr_attendance_rfid/__manifest__.py @@ -1,11 +1,10 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Comunitea Servicios Tecnológicos S.L. # Copyright 2018 Eficent Business and IT Consulting Services, S.L. # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html { 'name': 'HR Attendance RFID', - 'version': '10.0.1.0.0', + 'version': '11.0.1.0.0', 'category': 'Human Resources', 'website': 'https://github.com/OCA/hr', 'author': 'Comunitea,' @@ -18,8 +17,8 @@ 'hr_attendance', ], 'data': [ - 'views/hr_employee_view.xml', 'security/hr_attendance_rfid.xml', 'security/ir.model.access.csv', + 'views/hr_employee_view.xml', ], } diff --git a/hr_attendance_rfid/models/__init__.py b/hr_attendance_rfid/models/__init__.py index 62e043074989..e11a62f98ca0 100644 --- a/hr_attendance_rfid/models/__init__.py +++ b/hr_attendance_rfid/models/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- from . import hr_employee diff --git a/hr_attendance_rfid/models/hr_employee.py b/hr_attendance_rfid/models/hr_employee.py index ece03c1a8e8c..281447f1d611 100644 --- a/hr_attendance_rfid/models/hr_employee.py +++ b/hr_attendance_rfid/models/hr_employee.py @@ -1,10 +1,9 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Comunitea Servicios Tecnológicos S.L. # Copyright 2018 Eficent Business and IT Consulting Services, S.L. # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html import logging -from odoo import api, models, fields, _ +from odoo import api, fields, models, _ _logger = logging.getLogger(__name__) @@ -66,7 +65,6 @@ def register_attendance(self, card_code): res['error_message'] = msg return res except Exception as e: - msg = e.message - _logger.error(msg) - res['error_message'] = msg + res['error_message'] = e + _logger.error(e) return res diff --git a/hr_attendance_rfid/readme/CONFIGURE.rst b/hr_attendance_rfid/readme/CONFIGURE.rst new file mode 100644 index 000000000000..db5325b38e65 --- /dev/null +++ b/hr_attendance_rfid/readme/CONFIGURE.rst @@ -0,0 +1,12 @@ +To use this module, you need to use an external system that calls the method +'register_attendance' of the model 'hr.employee' passing as parameter the +code of the RFID card. + +Developers of a compatible RFID based employee attendance system should +be familiar with the outputs of this method and implement proper calls and +management of responses. + +It is advisory to create an exclusive user to perform this task. As +user doesn't need several access, it is just essential to perform the check +in/out, a group has been created. Add your attendance device user to +RFID Attendance group. \ No newline at end of file diff --git a/hr_attendance_rfid/readme/CONTRIBUTORS.rst b/hr_attendance_rfid/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..010a131c8cc3 --- /dev/null +++ b/hr_attendance_rfid/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Omar Catiñeira Saavedra +* Héctor Villarreal Ortega +* Jordi Ballester Alomar \ No newline at end of file diff --git a/hr_attendance_rfid/readme/DESCRIPTION.rst b/hr_attendance_rfid/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..6eb1dd18d78a --- /dev/null +++ b/hr_attendance_rfid/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module extends the functionality of HR Attendance in order to allow +the logging of employee attendances using an RFID based employee +attendance system. \ No newline at end of file diff --git a/hr_attendance_rfid/readme/USAGE.rst b/hr_attendance_rfid/readme/USAGE.rst new file mode 100644 index 000000000000..fed622546521 --- /dev/null +++ b/hr_attendance_rfid/readme/USAGE.rst @@ -0,0 +1,7 @@ +#. The HR employee responsible to set up new employees should go to + 'Attendances -> Manage Attendances -> Employees' and register the + RFID card code of each of your employees. You can use an USB plugged + RFID reader connected to your computer for this purpose. +#. The employee should put his/her card to the RFID based employee + attendance system. It is expected that the system will provide some form + of output of the registration event. \ No newline at end of file diff --git a/hr_attendance_rfid/security/hr_attendance_rfid.xml b/hr_attendance_rfid/security/hr_attendance_rfid.xml index bcdf9c741688..20777e943dd3 100644 --- a/hr_attendance_rfid/security/hr_attendance_rfid.xml +++ b/hr_attendance_rfid/security/hr_attendance_rfid.xml @@ -1,9 +1,7 @@ - - - RFID Attendance - - - - \ No newline at end of file + + RFID Attendance + + + diff --git a/hr_attendance_rfid/static/description/index.html b/hr_attendance_rfid/static/description/index.html new file mode 100644 index 000000000000..4a2ffc4ddb04 --- /dev/null +++ b/hr_attendance_rfid/static/description/index.html @@ -0,0 +1,429 @@ + + + + + + +HR Attendance RFID + + + +
+

HR Attendance RFID

+ + +

Beta License: AGPL-3 OCA/hr Translate me on Weblate Try me on Runbot

+

This module extends the functionality of HR Attendance in order to allow +the logging of employee attendances using an RFID based employee +attendance system.

+

Table of contents

+ +
+

Configuration

+

To use this module, you need to use an external system that calls the method +‘register_attendance’ of the model ‘hr.employee’ passing as parameter the +code of the RFID card.

+

Developers of a compatible RFID based employee attendance system should +be familiar with the outputs of this method and implement proper calls and +management of responses.

+

It is advisory to create an exclusive user to perform this task. As +user doesn’t need several access, it is just essential to perform the check +in/out, a group has been created. Add your attendance device user to +RFID Attendance group.

+
+
+

Usage

+
    +
  1. The HR employee responsible to set up new employees should go to +‘Attendances -> Manage Attendances -> Employees’ and register the +RFID card code of each of your employees. You can use an USB plugged +RFID reader connected to your computer for this purpose.
  2. +
  3. The employee should put his/her card to the RFID based employee +attendance system. It is expected that the system will provide some form +of output of the registration event.
  4. +
+
+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Comunitea
  • +
  • Eficent
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/hr_attendance_rfid/tests/__init__.py b/hr_attendance_rfid/tests/__init__.py index d1cab37d0434..bf71fa011450 100644 --- a/hr_attendance_rfid/tests/__init__.py +++ b/hr_attendance_rfid/tests/__init__.py @@ -1,3 +1,2 @@ -# -*- coding: utf-8 -*- from . import test_hr_attendance_rfid_process diff --git a/hr_attendance_rfid/tests/test_hr_attendance_rfid_process.py b/hr_attendance_rfid/tests/test_hr_attendance_rfid_process.py index ee143450729f..321badba6e36 100644 --- a/hr_attendance_rfid/tests/test_hr_attendance_rfid_process.py +++ b/hr_attendance_rfid/tests/test_hr_attendance_rfid_process.py @@ -1,8 +1,10 @@ -# -*- coding: utf-8 -*- # Copyright 2018 Eficent Business and IT Consulting Services, S.L. # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from datetime import datetime, timedelta from odoo.tests.common import TransactionCase +from odoo.tools.misc import mute_logger +from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT class TestHrAttendance(TransactionCase): @@ -28,6 +30,21 @@ def test_valid_employee(self): self.assertTrue('action' in res and res['action'] == 'check_out') self.assertTrue('logged' in res and res['logged']) + @mute_logger('odoo.addons.hr_attendance_rfid.models.hr_employee') + def test_exception_code(self): + """Checkout is created for a future datetime""" + self.env['hr.attendance'].create({ + 'employee_id': self.test_employee.id, + 'check_in': datetime.today().strftime( + DEFAULT_SERVER_DATETIME_FORMAT), + 'check_out': (datetime.today()+timedelta(hours=8)).strftime( + DEFAULT_SERVER_DATETIME_FORMAT), + }) + self.test_employee.update({'attendance_state': 'checked_in'}) + res = self.employee_model.register_attendance( + self.rfid_card_code) + self.assertNotEquals(res['error_message'], '') + def test_invalid_code(self): """Invalid employee""" invalid_code = '029238d'