diff --git a/hr_biometric_attendance/README.rst b/hr_biometric_attendance/README.rst new file mode 100644 index 000000000..ed754f64d --- /dev/null +++ b/hr_biometric_attendance/README.rst @@ -0,0 +1,64 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +HR Biometric Device Integration +=============================== +This Cybrosys's module integrates Odoo attendance with biometric device attendance. + +Configuration +============ +* This integration is applicable for the the ZK Devices. +* zklib you can install zklib library using "sudo pip install zklib" + +Compatible Devices +---------------- +This module support with the following machines + +* uFace202 (ZKteco) +* iFace990 (ZKteco) + +Clients have reported that the module works well with the following machine + +* K40 Pro (ZKteco) +* SFace900 (ZKteco) +* FR1500 (ZKteco) +* UA760 (ZKteco) +* MB10 (ZKteco + +License +------- +General Public License, Version 3 (AGPL-3). +(https://www.gnu.org/licenses/agpl-3.0-standalone.html) + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +* Developers: (V17) Mufeeda Shirin, + (V16) Nihala KP + + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Maintainer +-------- +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit https://www.cybrosys.com + +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com" + +Further Information +----------- +HTML Description: ``__ diff --git a/hr_biometric_attendance/__init__.py b/hr_biometric_attendance/__init__.py new file mode 100644 index 000000000..8ef0a35c5 --- /dev/null +++ b/hr_biometric_attendance/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from . import models +from . import wizards diff --git a/hr_biometric_attendance/__manifest__.py b/hr_biometric_attendance/__manifest__.py new file mode 100644 index 000000000..ba57dcb8b --- /dev/null +++ b/hr_biometric_attendance/__manifest__.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +{ + 'name': "HR Biometric Device Integration", + 'version': "16.0.1.0.0", + 'summary': "Integrating Zk Biometric Devices With HR Attendance", + 'description': '''This module integrates Odoo with ZK biometric devices, + incorporating features such as live capturing and user management''', + 'category': 'Human Resources', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'depends': ['base_setup', 'hr_attendance', 'web'], + 'data': [ + 'security/ir.model.access.csv', + 'data/ir_cron_data.xml', + 'data/ir_action_data.xml', + 'wizards/user_management_views.xml', + 'wizards/employee_biometric_views.xml', + 'views/biometric_device_details_views.xml', + 'views/hr_employee_views.xml', + 'views/daily_attendance_views.xml', + 'views/res_config_settings_views.xml', + 'views/biometric_device_attendance_menus.xml', + ], + 'assets': { + 'web.assets_backend': [ + 'hr_biometric_attendance/static/src/xml/stopwatch_view.xml', + 'hr_biometric_attendance/static/src/js/stopwatch.js', + ] + }, + 'external_dependencies': { + 'python': ['pyzk'], }, + 'images': ['static/description/banner.png'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/hr_biometric_attendance/data/ir_action_data.xml b/hr_biometric_attendance/data/ir_action_data.xml new file mode 100644 index 000000000..c52bf96d2 --- /dev/null +++ b/hr_biometric_attendance/data/ir_action_data.xml @@ -0,0 +1,14 @@ + + + + + Biometric Device + + + form + code + + action = records.action_biometric_device() + + + diff --git a/hr_biometric_attendance/data/ir_cron_data.xml b/hr_biometric_attendance/data/ir_cron_data.xml new file mode 100644 index 000000000..0a3819eb2 --- /dev/null +++ b/hr_biometric_attendance/data/ir_cron_data.xml @@ -0,0 +1,14 @@ + + + + + Schedule Attendance Downloading + + code + model.schedule_attendance() + 1 + days + -1 + + + diff --git a/hr_biometric_attendance/doc/RELEASE_NOTES.md b/hr_biometric_attendance/doc/RELEASE_NOTES.md new file mode 100755 index 000000000..474cf4c27 --- /dev/null +++ b/hr_biometric_attendance/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 25.07.2024 +#### Version 16.0.1.0.0 +#### ADD +- Initial commit for HR Biometric Device Integration diff --git a/hr_biometric_attendance/models/__init__.py b/hr_biometric_attendance/models/__init__.py new file mode 100644 index 000000000..800836842 --- /dev/null +++ b/hr_biometric_attendance/models/__init__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from . import biometric_device_details +from . import zk_machine_attendance +from . import daily_attendance +from . import fingerprint_templates +from . import hr_employee +from . import res_config_settings diff --git a/hr_biometric_attendance/models/biometric_device_details.py b/hr_biometric_attendance/models/biometric_device_details.py new file mode 100644 index 000000000..98ab12f75 --- /dev/null +++ b/hr_biometric_attendance/models/biometric_device_details.py @@ -0,0 +1,635 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +import base64 +import binascii +import datetime +import logging +import threading +from threading import Thread +import time +import pytz +from zk.exception import ZKErrorResponse +from odoo import api, fields, models, registry, _ +from odoo.exceptions import UserError, ValidationError +live_capture_thread = None +_logger = logging.getLogger(__name__) +try: + from zk import const, ZK + from zk.finger import Finger +except ImportError: + _logger.error("Please Install pyzk library.") + + +class BiometricDeviceDetails(models.Model): + """Model for configuring and connect the biometric device with odoo""" + _name = 'biometric.device.details' + _description = 'Biometric Device Details' + _inherit = ['mail.thread', 'mail.activity.mixin'] + + name = fields.Char(string='Name', required=True, help='Record Name') + device_ip = fields.Char(string='Device IP', required=True, + help='The IP address of the Device') + port_number = fields.Integer(string='Port Number', required=True, + help="The Port Number of the Device") + address_id = fields.Many2one('res.partner', string='Working Address', + help='Working address of the partner') + is_live_capture = fields.Boolean('Live Capturing', + help="if enabled, gets the live capture " + "from the device", + readonly=True) + company_id = fields.Many2one('res.company', string='Company', + default=lambda + self: self.env.user.company_id.id, + help='Current Company') + stopwatch_time = fields.Float('Stopwatch timer', + help='Time from Live capture enabled') + device_name = fields.Char(String='Device Name', readonly=True, + help='Device Name') + device_firmware = fields.Char(String='Device Firmware Version', + readonly=True, help='Device Firmware') + device_serial_no = fields.Char(String='Device Serial No', readonly=True, + help='Device serial No') + device_platform = fields.Char(String='Device Platform', readonly=True, + help='Device platform') + device_mac = fields.Char(String='Device Mac ID', readonly=True, + help='Device Mac') + live_capture_start_time = fields.Datetime('Live Capture Time', + help='The Time When Live ' + 'Capture Enabled') + + def device_connect(self, zk): + """Function for connecting the device with Odoo""" + try: + conn = zk.connect() + return conn + except Exception: + return False + + def action_test_connection(self): + """Checking the connection status""" + zk = ZK(self.device_ip, port=self.port_number, timeout=30, + password=False, ommit_ping=False) + try: + if zk.connect(): + zk.test_voice(index=0) + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'message': 'Successfully Connected', + 'type': 'success', + 'sticky': False + } + } + + except Exception as error: + raise ValidationError(f'{error}') + + def action_clear_attendance(self): + """Methode to clear record from the zk.machine.attendance model and + from the device""" + for info in self: + try: + machine_ip = info.device_ip + zk_port = info.port_number + try: + # Connecting with the device + zk = ZK(machine_ip, port=zk_port, timeout=30, + password=0, force_udp=False, ommit_ping=False) + except NameError: + raise UserError(_( + "Please install it with 'pip3 install pyzk'.")) + conn = self.device_connect(zk) + if conn: + conn.enable_device() + clear_data = zk.get_attendance() + if clear_data: + # Clearing data in the device + conn.clear_attendance() + # Clearing data from attendance log + self._cr.execute( + """delete from zk_machine_attendance""") + current_time = fields.datetime.now().strftime( + '%Y-%m-%d %H:%M:%S') + message = (f'Attendances Are cleared from the Device on' + f' {current_time} By {self.env.user.name}') + self.message_post(body=message) + conn.disconnect() + else: + raise UserError( + _('Unable to clear Attendance log.Are you sure ' + 'attendance log is not empty.')) + else: + raise UserError( + _('Unable to connect to Attendance Device. Please use ' + 'Test Connection button to verify.')) + except Exception as error: + raise ValidationError(f'{error}') + + def action_download_attendance(self): + """Function to download attendance records from the device""" + _logger.info("++++++++++++Cron Executed++++++++++++++++++++++") + zk_attendance = self.env['zk.machine.attendance'] + hr_attendance = self.env['hr.attendance'] + for info in self: + machine_ip = info.device_ip + zk_port = info.port_number + try: + # Connecting with the device with the ip and port provided + zk = ZK(machine_ip, port=zk_port, timeout=15, + password=0, + force_udp=False, ommit_ping=False) + except NameError: + raise UserError( + _("Pyzk module not Found. Please install it" + "with 'pip3 install pyzk'.")) + conn = self.device_connect(zk) + self.get_device_information() + if conn: + conn.disable_device() + self.get_all_users() + self.action_set_timezone() + user = conn.get_users() + # get All Fingerprints + fingers = conn.get_templates() + for use in user: + for finger in fingers: + if finger.uid == use.uid: + templates = conn.get_user_template(uid=use.uid, + temp_id=finger.fid, + user_id=use.user_id) + hex_data = templates.template.hex() + # Convert hex data to binary + binary_data = binascii.unhexlify(hex_data) + base64_data = base64.b64encode(binary_data).decode( + 'utf-8') + employee = self.env['hr.employee'].search( + [('device_id_num', '=', use.user_id)]) + employee.write({ + 'device_id': self.id, + }) + if str(finger.fid) in employee.fingerprint_ids.mapped( + 'finger_id'): + employee.fingerprint_ids.search( + [('finger_id', '=', finger.fid)]).update({ + 'finger_template': base64_data, + }) + else: + employee.fingerprint_ids.create({ + 'finger_template': base64_data, + 'finger_id': finger.fid, + 'employee_id': employee.id, + 'filename': f'{employee.name}-finger-{finger.fid}' + }) + # get all attendances + attendance = conn.get_attendance() + if attendance: + for each in attendance: + atten_time = each.timestamp + local_tz = pytz.timezone( + self.env.user.partner_id.tz or 'GMT') + local_dt = local_tz.localize(atten_time, is_dst=None) + utc_dt = local_dt.astimezone(pytz.utc) + utc_dt = utc_dt.strftime("%Y-%m-%d %H:%M:%S") + atten_time = datetime.datetime.strptime( + utc_dt, "%Y-%m-%d %H:%M:%S") + atten_time = fields.Datetime.to_string(atten_time) + for uid in user: + if uid.user_id == each.user_id: + get_user_id = self.env['hr.employee'].search( + [('device_id_num', '=', each.user_id)]) + if get_user_id: + duplicate_atten_ids = zk_attendance.search( + [('device_id_num', '=', each.user_id), + ('punching_time', '=', atten_time)]) + if not duplicate_atten_ids: + zk_attendance.create({ + 'employee_id': get_user_id.id, + 'device_id_num': each.user_id, + 'attendance_type': str(each.status), + 'punch_type': str(each.punch), + 'punching_time': atten_time, + 'address_id': info.address_id.id + }) + att_var = hr_attendance.search([( + 'employee_id', '=', get_user_id.id), + ('check_out', '=', False)]) + if each.punch == 0: # check-in + if not att_var: + hr_attendance.create({ + 'employee_id': + get_user_id.id, + 'check_in': atten_time + }) + if each.punch == 1: # check-out + if len(att_var) == 1: + att_var.write({ + 'check_out': atten_time + }) + else: + att_var1 = hr_attendance.search( + [('employee_id', '=', + get_user_id.id)]) + if att_var1: + att_var1[-1].write({ + 'check_out': atten_time + }) + else: + employee = self.env['hr.employee'].create({ + 'device_id_num': each.user_id, + 'device_id': self.id, + 'name': uid.name + }) + zk_attendance.create({ + 'employee_id': employee.id, + 'device_id_num': each.user_id, + 'attendance_type': str(each.status), + 'punch_type': str(each.punch), + 'punching_time': atten_time, + 'address_id': info.address_id.id + }) + hr_attendance.create({ + 'employee_id': employee.id, + 'check_in': atten_time + }) + if not self.is_live_capture: + current_time = fields.datetime.now().strftime( + '%Y-%m-%d %H:%M:%S') + message = (f'Downloaded data from the device on ' + f'{current_time} by {self.env.user.name}') + self.message_post(body=message) + conn.disconnect() + return True + else: + zk.test_voice(index=4) + raise UserError(_('Unable to get the attendance log, please' + 'try again later.')) + else: + raise UserError(_('Unable to connect, please check the' + 'parameters and network connections.')) + + def action_restart_device(self): + """For restarting the device""" + zk = ZK(self.device_ip, port=self.port_number, timeout=15, + password=0, + force_udp=False, ommit_ping=False) + if self.device_connect(zk): + if self.is_live_capture: + self.action_stop_live_capture() + self.device_connect(zk).restart() + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'message': 'Successfully Device Restarted', + 'type': 'success', + 'sticky': False + } + } + else: + raise UserError(_( + "Please Check the Connection")) + + def schedule_attendance(self): + """Schedule action for attendance downloading""" + for record in self.search([]): + if record.is_live_capture: + record.action_stop_live_capture() + record.action_download_attendance() + record.action_live_capture() + else: + record.action_download_attendance() + + def action_live_capture(self): + """ Enable Live capture With Thread""" + for info in self: + machine_ip = info.device_ip + zk_port = info.port_number + try: + self.is_live_capture = True + self.action_set_timezone() + instance = ZKBioAttendance(machine_ip, zk_port, info) + global live_capture_thread + live_capture_thread = instance + live_capture_thread.start() + self.live_capture_start_time = fields.datetime.now() + return { + 'type': 'ir.actions.client', + 'tag': 'reload', + } + except NameError: + raise UserError(_( + "Please install it with 'pip3 install pyzk'.")) + + def action_stop_live_capture(self): + """Function to stop Live capture""" + try: + self.is_live_capture = False + if live_capture_thread: + live_capture_thread.stop() + return { + 'type': 'ir.actions.client', + 'tag': 'reload', + } + except NameError: + raise UserError(_( + "Please install it with 'pip3 install pyzk'.")) + + def action_set_timezone(self): + """Function to set user's timezone to device""" + for info in self: + machine_ip = info.device_ip + zk_port = info.port_number + try: + # Connecting with the device with the ip and port provided + zk = ZK(machine_ip, port=zk_port, timeout=15, + password=0, + force_udp=False, ommit_ping=False) + except NameError: + raise UserError( + _("Pyzk module not Found. Please install it" + "with 'pip3 install pyzk'.")) + conn = self.device_connect(zk) + if conn: + user_tz = self.env.context.get( + 'tz') or self.env.user.tz or 'UTC' + user_timezone_time = pytz.utc.localize(fields.Datetime.now()) + user_timezone_time = user_timezone_time.astimezone( + pytz.timezone(user_tz)) + conn.set_time(user_timezone_time) + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'message': 'Successfully Set the Time', + 'type': 'success', + 'sticky': False + } + } + else: + raise UserError(_( + "Please Check the Connection")) + + def get_all_users(self): + """Function to get all user's details""" + for info in self: + machine_ip = info.device_ip + zk_port = info.port_number + try: + # Connecting with the device with the ip and port provided + zk = ZK(machine_ip, port=zk_port, timeout=15, + password=0, + force_udp=False, ommit_ping=False) + except NameError: + raise UserError( + _("Pyzk module not Found. Please install it" + "with 'pip3 install pyzk'.")) + conn = self.device_connect(zk) + if conn: + users = conn.get_users() + for user in users: + employee = self.env['hr.employee'].search( + [('device_id_num', '=', user.user_id), + ('device_id', '=', self.id)]) + if employee: + employee.write({ + 'name': user.name, + }) + else: + self.env['hr.employee'].create({ + 'name': user.name, + 'device_id_num': user.user_id, + 'device_id': self.id, + }) + else: + raise UserError(_( + "Please Check the Connection")) + + def set_user(self, employee_id): + """Function to create or update users""" + for info in self: + machine_ip = info.device_ip + zk_port = info.port_number + employee = self.env['hr.employee'].browse(int(employee_id)) + try: + # Connecting with the device with the ip and port provided + zk = ZK(machine_ip, port=zk_port, timeout=15, + password=0, + force_udp=False, ommit_ping=False) + except NameError: + raise UserError( + _("Pyzk module not Found. Please install it" + "with 'pip3 install pyzk'.")) + conn = self.device_connect(zk) + if conn: + last_user = conn.get_users()[-1] + privilege = 0 + password = '' + group_id = '' + user_id = '' + card = 0 + try: + uids = [user.uid for user in conn.get_users()] + candidate_uid = last_user.uid + 1 + while candidate_uid in uids: + candidate_uid += 1 + conn.set_user(candidate_uid, employee.name, privilege, + password, group_id, user_id, card) + except ZKErrorResponse as e: + _logger.error("Failed to set user on the device: %s", + str(e)) + if conn.get_users()[-1].name == employee.name: + employee.write({ + 'device_id': self.id, + 'device_id_num': conn.get_users()[-1].user_id + }) + current_time = fields.datetime.now().strftime( + '%Y-%m-%d %H:%M:%S') + message = (f'New User {employee.name} Created on ' + f'{current_time} by {self.env.user.name}') + self.message_post(body=message) + else: + raise UserError(_( + "Please Check the Connection")) + + def delete_user(self, employee_id, delete_user_selection): + """Function to Delete a user""" + for info in self: + machine_ip = info.device_ip + zk_port = info.port_number + try: + # Connecting with the device with the ip and port provided + zk = ZK(machine_ip, port=zk_port, timeout=15, + password=0, + force_udp=False, ommit_ping=False) + except NameError: + raise UserError( + _("Pyzk module not Found. Please install it" + "with 'pip3 install pyzk'.")) + conn = self.device_connect(zk) + if conn: + employee = self.env['hr.employee'].browse(int(employee_id)) + employee_name = employee.name + conn.delete_user(uid=None, user_id=employee.device_id_num) + employee.write({ + 'device_id_num': False, + 'device_id': False + }) + employee.fingerprint_ids.unlink() + if delete_user_selection == 'both_device': + employee.unlink() + current_time = fields.datetime.now().strftime( + '%Y-%m-%d %H:%M:%S') + message = (f'Deleted User {employee_name} on ' + f'{current_time} by {self.env.user.name}') + self.message_post(body=message) + else: + raise UserError(_( + "Please Check the Connection")) + + def update_user(self, employee_id): + """Function to Update a user""" + for info in self: + machine_ip = info.device_ip + zk_port = info.port_number + try: + # Connecting with the device with the ip and port provided + zk = ZK(machine_ip, port=zk_port, timeout=15, + password=0, + force_udp=False, ommit_ping=False) + except NameError: + raise UserError( + _("Pyzk module not Found. Please install it" + "with 'pip3 install pyzk'.")) + conn = self.device_connect(zk) + if conn: + employee = self.env['hr.employee'].browse(int(employee_id)) + for line in conn.get_users(): + if line.user_id == employee.device_id_num: + privilege = 0 + password = '' + group_id = '' + user_id = employee.device_id_num + card = 0 + conn.set_user(line.uid, employee.name, privilege, + password, group_id, user_id, card) + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'message': 'Successfully Updated User', + 'type': 'success', + 'sticky': False + } + } + else: + raise UserError(_( + "Please Check the Connection")) + + def get_device_information(self): + """Gets device Information""" + for info in self: + machine_ip = info.device_ip + zk_port = info.port_number + try: + # Connecting with the device with the ip and port provided + zk = ZK(machine_ip, port=zk_port, timeout=15, + password=0, + force_udp=False, ommit_ping=False) + except NameError: + raise UserError( + _("Pyzk module not Found. Please install it" + "with 'pip3 install pyzk'.")) + conn = self.device_connect(zk) + if conn: + self.device_name = conn.get_device_name() + self.device_firmware = conn.get_firmware_version() + self.device_serial_no = conn.get_serialnumber() + self.device_platform = conn.get_platform() + self.device_mac = conn.get_mac() + else: + raise UserError(_( + "Please Check the Connection")) + + +class ZKBioAttendance(Thread): + """ + Represents a thread for capturing live attendance data from a ZKTeco + biometric device. + + Attributes: - machine_ip: The IP address of the ZKTeco biometric device. + - port_no: The port number for communication with the ZKTeco biometric + device. - conn: The connection object to the ZKTeco biometric device. + + Methods: - run(): Overrides the run method of the Thread class to capture + live attendance data. + """ + + def __init__(self, machine_ip, port_no, record): + """Function to Initialize the thread""" + Thread.__init__(self) + self.machine_ip = machine_ip + self.port_no = port_no + self.record = record + self.env = record.env + self.stop_event = threading.Event() + + zk_device = ZK( + machine_ip, + port=port_no, + timeout=5, + password=0, + force_udp=False, + ommit_ping=False, + ) + conn = zk_device.connect() + if conn: + self.conn = conn + else: + raise UserError(_( + "Please Check the Connection")) + + def run(self): + """Function to run the Thread""" + while not self.stop_event.is_set(): + try: + if not self.conn.end_live_capture: + for attendance in self.conn.live_capture(2000): + self._data_live_capture() + time.sleep(10) + except Exception as e: + self.env.cr.rollback() # Rollback the current transaction + time.sleep(1) + + def stop(self): + """Stops the live capture and stops the thread""" + if self.conn: + self.conn.end_live_capture = True + self.stop_event.set() + + def _data_live_capture(self): + """Updated the Live Capture real time""" + with registry(self.env.cr.dbname).cursor() as new_cr: + new_env = api.Environment(new_cr, self.env.uid, self.env.context) + if self.conn.get_attendance(): + self.record.with_env(new_env).action_download_attendance() + new_cr.commit() diff --git a/hr_biometric_attendance/models/daily_attendance.py b/hr_biometric_attendance/models/daily_attendance.py new file mode 100644 index 000000000..f0fc95aec --- /dev/null +++ b/hr_biometric_attendance/models/daily_attendance.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from odoo import fields, models, tools + + +class DailyAttendance(models.Model): + """Model to hold data from the biometric device""" + _name = 'daily.attendance' + _description = 'Daily Attendance Report' + _auto = False + _order = 'punching_day desc' + + employee_id = fields.Many2one('hr.employee', string='Employee', + help='Employee Name') + punching_day = fields.Datetime(string='Date', help='Date of punching') + address_id = fields.Many2one('res.partner', string='Working Address', + help='Working address of the employee') + attendance_type = fields.Selection([('1', 'Finger'), ('15', 'Face'), + ('2', 'Type_2'), ('3', 'Password'), + ('4', 'Card')], string='Category', + help='Attendance detecting methods') + punch_type = fields.Selection([('0', 'Check In'), ('1', 'Check Out'), + ('2', 'Break Out'), ('3', 'Break In'), + ('4', 'Overtime In'), ('5', 'Overtime Out')], + string='Punching Type', + help='The Punching Type of attendance') + punching_time = fields.Datetime(string='Punching Time', + help='Punching time in the device') + + def init(self): + """Retrieve the data's for attendance report""" + tools.drop_view_if_exists(self._cr, 'daily_attendance') + query = """ + create or replace view daily_attendance as ( + select + min(z.id) as id, + z.employee_id as employee_id, + z.write_date as punching_day, + z.address_id as address_id, + z.attendance_type as attendance_type, + z.punching_time as punching_time, + z.punch_type as punch_type + from zk_machine_attendance z + join hr_employee e on (z.employee_id=e.id) + GROUP BY + z.employee_id, + z.write_date, + z.address_id, + z.attendance_type, + z.punch_type, + z.punching_time + ) + """ + self._cr.execute(query) diff --git a/hr_biometric_attendance/models/fingerprint_templates.py b/hr_biometric_attendance/models/fingerprint_templates.py new file mode 100644 index 000000000..c0ed98ef8 --- /dev/null +++ b/hr_biometric_attendance/models/fingerprint_templates.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from odoo import fields, models + + +class FingerprintTemplates(models.Model): + """Inherit the model to add field""" + _name = 'fingerprint.templates' + _description = 'Finger Print Templates for Employee' + + employee_id = fields.Many2one('hr.employee', string='Employee', + help='The Employee ') + finger_id = fields.Char(string='Finger Id', + help='The Number that refers the Finger') + filename = fields.Char(string='Finger File Name', + help='File Name of the Uploaded Finger Print') + finger_template = fields.Binary(string='Finger Template', + help='The Uploaded Finger Print file') diff --git a/hr_biometric_attendance/models/hr_employee.py b/hr_biometric_attendance/models/hr_employee.py new file mode 100644 index 000000000..865728b44 --- /dev/null +++ b/hr_biometric_attendance/models/hr_employee.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from odoo import fields, models, _ + + +class HrEmployee(models.Model): + """Inherit the model to add field""" + _inherit = 'hr.employee' + + device_id_num = fields.Char(string='Biometric Device ID', + help="Give the biometric device id", copy=False) + device_id = fields.Many2one('biometric.device.details', copy=False, + readonly=True, + help='The biometric device details') + fingerprint_ids = fields.One2many('fingerprint.templates', 'employee_id', + help='Store finger print templates of ' + 'an employee') + + def action_biometric_device(self): + """Server Action for Biometric Device which open a wizard with + several options""" + return { + 'type': 'ir.actions.act_window', + 'target': 'new', + 'name': _('Biometric Management'), + 'view_mode': 'form', + 'res_model': 'employee.biometric', + 'context': {'default_employee_id': self.id}, + } diff --git a/hr_biometric_attendance/models/res_config_settings.py b/hr_biometric_attendance/models/res_config_settings.py new file mode 100644 index 000000000..308165277 --- /dev/null +++ b/hr_biometric_attendance/models/res_config_settings.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from datetime import timedelta +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + """ Inherited res.config.settings to add new fields """ + _inherit = 'res.config.settings' + + schedule_attendance_downloads = fields.Boolean(string="Schedule Downloads", + config_parameter='hr_biometric_attendance.schedule_downloads', + default=False, + help='If Enabled we can ' + 'schedule attendance ' + 'downloading from ' + 'device') + schedule_time_interval = fields.Integer(string="Schedule Time Interval", + config_parameter='hr_biometric_attendance.schedule_time_interval', + default=1, + help='We can set Time interval ' + 'for the Scheduling') + schedule_time_period = fields.Selection( + selection=[('hours', 'Hours'), ('days', 'Days')], + string="Schedule Time Period", + config_parameter='hr_biometric_attendance.schedule_time_period', + default='days', help='We can set Time Period for the Scheduling') + + def set_values(self): + """ Super the function to set the values from settings to the + cron.job""" + super().set_values() + if self.schedule_attendance_downloads: + self.env['ir.cron'].search( + [('name', '=', 'Schedule Attendance Downloading')]).write({ + 'active': True, + 'interval_type': self.schedule_time_period, + 'interval_number': self.schedule_time_interval, + 'nextcall': fields.datetime.now() + timedelta( + hours=self.schedule_time_interval) if + self.schedule_time_period == 'hours' else + fields.datetime.now() + timedelta( + days=self.schedule_time_interval), + }) + else: + self.env['ir.cron'].search( + [('name', '=', 'Schedule Attendance Downloading')]).write({ + 'active': False + }) diff --git a/hr_biometric_attendance/models/zk_machine_attendance.py b/hr_biometric_attendance/models/zk_machine_attendance.py new file mode 100644 index 000000000..8b427f6db --- /dev/null +++ b/hr_biometric_attendance/models/zk_machine_attendance.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from odoo import api, fields, models + + +class ZkMachineAttendance(models.Model): + """Model to hold data from the biometric device""" + _name = 'zk.machine.attendance' + _description = 'Attendance' + _inherit = 'hr.attendance' + + @api.constrains('check_in', 'check_out', 'employee_id') + def _check_validity(self): + """Overriding the __check_validity function for employee attendance.""" + pass + + device_id_num = fields.Char(string='Biometric Device ID', + help="The ID of the Biometric Device") + punch_type = fields.Selection([('0', 'Check In'), ('1', 'Check Out'), + ('2', 'Break Out'), ('3', 'Break In'), + ('4', 'Overtime In'), ('5', 'Overtime Out'), + ('255', 'Duplicate')], + string='Punching Type', + help='Punching type of the attendance') + attendance_type = fields.Selection([('1', 'Finger'), ('15', 'Face'), + ('2', 'Type_2'), ('3', 'Password'), + ('4', 'Card'), ('255', 'Duplicate')], + string='Category', + help="Attendance detecting methods") + punching_time = fields.Datetime(string='Punching Time', + help="Punching time in the device") + address_id = fields.Many2one('res.partner', string='Working Address', + help="Working address of the employee") diff --git a/hr_biometric_attendance/security/ir.model.access.csv b/hr_biometric_attendance/security/ir.model.access.csv new file mode 100644 index 000000000..b5c6bcb04 --- /dev/null +++ b/hr_biometric_attendance/security/ir.model.access.csv @@ -0,0 +1,7 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_biometric_device_details,access.biometric.device.details,model_biometric_device_details,base.group_user,1,1,1,1 +access_daily_attendance,access.daily.attendance,model_daily_attendance,base.group_user,1,1,1,1 +access_zk_machine_attendance,access.zk.machine.attendance,model_zk_machine_attendance,base.group_user,1,1,1,1 +access_zk_user_management,access.zk.user.management,model_zk_user_management,base.group_user,1,1,1,1 +access_employee_biometric,access.employee.biometric,model_employee_biometric,base.group_user,1,1,1,1 +access_clear_fingerprint_templates,access.fingerprint.templates,model_fingerprint_templates,base.group_user,1,1,1,1 diff --git a/hr_biometric_attendance/static/description/assets/cybro-odoo.png b/hr_biometric_attendance/static/description/assets/cybro-odoo.png new file mode 100644 index 000000000..ed02e07a4 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/cybro-odoo.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/check.png b/hr_biometric_attendance/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/check.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/chevron.png b/hr_biometric_attendance/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/chevron.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/cogs.png b/hr_biometric_attendance/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/cogs.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/consultation.png b/hr_biometric_attendance/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/consultation.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/ecom-black.png b/hr_biometric_attendance/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/ecom-black.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/education-black.png b/hr_biometric_attendance/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/education-black.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/faq.png b/hr_biometric_attendance/static/description/assets/icons/faq.png new file mode 100644 index 000000000..4250b5b81 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/faq.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/feature.png b/hr_biometric_attendance/static/description/assets/icons/feature.png new file mode 100644 index 000000000..ac7a785c0 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/feature.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/hotel-black.png b/hr_biometric_attendance/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/hotel-black.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/license.png b/hr_biometric_attendance/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/license.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/lifebuoy.png b/hr_biometric_attendance/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/lifebuoy.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/manufacturing-black.png b/hr_biometric_attendance/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/manufacturing-black.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/notes.png b/hr_biometric_attendance/static/description/assets/icons/notes.png new file mode 100644 index 000000000..ee5e95404 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/notes.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/pos-black.png b/hr_biometric_attendance/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/pos-black.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/puzzle.png b/hr_biometric_attendance/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/puzzle.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/restaurant-black.png b/hr_biometric_attendance/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/restaurant-black.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/screenshot.png b/hr_biometric_attendance/static/description/assets/icons/screenshot.png new file mode 100644 index 000000000..cef272529 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/screenshot.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/service-black.png b/hr_biometric_attendance/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/service-black.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/skype.png b/hr_biometric_attendance/static/description/assets/icons/skype.png new file mode 100644 index 000000000..51b409fb3 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/skype.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/star-1.svg b/hr_biometric_attendance/static/description/assets/icons/star-1.svg new file mode 100644 index 000000000..7e55ab162 --- /dev/null +++ b/hr_biometric_attendance/static/description/assets/icons/star-1.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hr_biometric_attendance/static/description/assets/icons/support.png b/hr_biometric_attendance/static/description/assets/icons/support.png new file mode 100644 index 000000000..4f18b8b82 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/support.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/test-1.png b/hr_biometric_attendance/static/description/assets/icons/test-1.png new file mode 100644 index 000000000..0908add2b Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/test-1.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/trading-black.png b/hr_biometric_attendance/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/trading-black.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/training.png b/hr_biometric_attendance/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/training.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/update.png b/hr_biometric_attendance/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/update.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/user.png b/hr_biometric_attendance/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/user.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/whatsapp.png b/hr_biometric_attendance/static/description/assets/icons/whatsapp.png new file mode 100644 index 000000000..d513a5356 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/whatsapp.png differ diff --git a/hr_biometric_attendance/static/description/assets/icons/wrench.png b/hr_biometric_attendance/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/icons/wrench.png differ diff --git a/hr_biometric_attendance/static/description/assets/misc/categories.png b/hr_biometric_attendance/static/description/assets/misc/categories.png new file mode 100644 index 000000000..bedf1e0b1 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/misc/categories.png differ diff --git a/hr_biometric_attendance/static/description/assets/misc/check-box.png b/hr_biometric_attendance/static/description/assets/misc/check-box.png new file mode 100644 index 000000000..42caf24b9 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/misc/check-box.png differ diff --git a/hr_biometric_attendance/static/description/assets/misc/compass.png b/hr_biometric_attendance/static/description/assets/misc/compass.png new file mode 100644 index 000000000..d5fed8faa Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/misc/compass.png differ diff --git a/hr_biometric_attendance/static/description/assets/misc/corporate.png b/hr_biometric_attendance/static/description/assets/misc/corporate.png new file mode 100644 index 000000000..2eb13edbf Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/misc/corporate.png differ diff --git a/hr_biometric_attendance/static/description/assets/misc/customer-support.png b/hr_biometric_attendance/static/description/assets/misc/customer-support.png new file mode 100644 index 000000000..79efc72ed Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/misc/customer-support.png differ diff --git a/hr_biometric_attendance/static/description/assets/misc/cybrosys-logo.png b/hr_biometric_attendance/static/description/assets/misc/cybrosys-logo.png new file mode 100644 index 000000000..cc3cc0ccf Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/misc/cybrosys-logo.png differ diff --git a/hr_biometric_attendance/static/description/assets/misc/features.png b/hr_biometric_attendance/static/description/assets/misc/features.png new file mode 100644 index 000000000..b41769f77 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/misc/features.png differ diff --git a/hr_biometric_attendance/static/description/assets/misc/logo.png b/hr_biometric_attendance/static/description/assets/misc/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/misc/logo.png differ diff --git a/hr_biometric_attendance/static/description/assets/misc/pictures.png b/hr_biometric_attendance/static/description/assets/misc/pictures.png new file mode 100644 index 000000000..56d255fe9 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/misc/pictures.png differ diff --git a/hr_biometric_attendance/static/description/assets/misc/pie-chart.png b/hr_biometric_attendance/static/description/assets/misc/pie-chart.png new file mode 100644 index 000000000..426e05244 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/misc/pie-chart.png differ diff --git a/hr_biometric_attendance/static/description/assets/misc/right-arrow.png b/hr_biometric_attendance/static/description/assets/misc/right-arrow.png new file mode 100644 index 000000000..730984a06 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/misc/right-arrow.png differ diff --git a/hr_biometric_attendance/static/description/assets/misc/star.png b/hr_biometric_attendance/static/description/assets/misc/star.png new file mode 100644 index 000000000..2eb9ab29f Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/misc/star.png differ diff --git a/hr_biometric_attendance/static/description/assets/misc/support.png b/hr_biometric_attendance/static/description/assets/misc/support.png new file mode 100644 index 000000000..4f18b8b82 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/misc/support.png differ diff --git a/hr_biometric_attendance/static/description/assets/misc/whatsapp.png b/hr_biometric_attendance/static/description/assets/misc/whatsapp.png new file mode 100644 index 000000000..d513a5356 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/misc/whatsapp.png differ diff --git a/hr_biometric_attendance/static/description/assets/modules/1.png b/hr_biometric_attendance/static/description/assets/modules/1.png new file mode 100644 index 000000000..ed11bd818 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/modules/1.png differ diff --git a/hr_biometric_attendance/static/description/assets/modules/2.png b/hr_biometric_attendance/static/description/assets/modules/2.png new file mode 100644 index 000000000..347c97957 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/modules/2.png differ diff --git a/hr_biometric_attendance/static/description/assets/modules/3.png b/hr_biometric_attendance/static/description/assets/modules/3.png new file mode 100644 index 000000000..812fefdb5 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/modules/3.png differ diff --git a/hr_biometric_attendance/static/description/assets/modules/4.png b/hr_biometric_attendance/static/description/assets/modules/4.png new file mode 100644 index 000000000..1077a4c4e Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/modules/4.png differ diff --git a/hr_biometric_attendance/static/description/assets/modules/5.png b/hr_biometric_attendance/static/description/assets/modules/5.png new file mode 100644 index 000000000..ac5cbdc80 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/modules/5.png differ diff --git a/hr_biometric_attendance/static/description/assets/modules/6.png b/hr_biometric_attendance/static/description/assets/modules/6.png new file mode 100644 index 000000000..e76acf229 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/modules/6.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/1.png b/hr_biometric_attendance/static/description/assets/screenshots/1.png new file mode 100644 index 000000000..000d3d130 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/1.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/10.png b/hr_biometric_attendance/static/description/assets/screenshots/10.png new file mode 100644 index 000000000..790272cc9 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/10.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/11.png b/hr_biometric_attendance/static/description/assets/screenshots/11.png new file mode 100644 index 000000000..36386f1be Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/11.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/12.png b/hr_biometric_attendance/static/description/assets/screenshots/12.png new file mode 100644 index 000000000..1e6915f02 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/12.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/13.png b/hr_biometric_attendance/static/description/assets/screenshots/13.png new file mode 100644 index 000000000..271818566 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/13.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/14.png b/hr_biometric_attendance/static/description/assets/screenshots/14.png new file mode 100644 index 000000000..c4803061e Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/14.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/15.png b/hr_biometric_attendance/static/description/assets/screenshots/15.png new file mode 100644 index 000000000..66491021a Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/15.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/16.png b/hr_biometric_attendance/static/description/assets/screenshots/16.png new file mode 100644 index 000000000..0bf87c044 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/16.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/17.png b/hr_biometric_attendance/static/description/assets/screenshots/17.png new file mode 100644 index 000000000..8a15878c0 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/17.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/18.png b/hr_biometric_attendance/static/description/assets/screenshots/18.png new file mode 100644 index 000000000..01b9e2bfa Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/18.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/19.png b/hr_biometric_attendance/static/description/assets/screenshots/19.png new file mode 100644 index 000000000..360aa4dbb Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/19.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/2.png b/hr_biometric_attendance/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..eead649a9 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/2.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/20.png b/hr_biometric_attendance/static/description/assets/screenshots/20.png new file mode 100644 index 000000000..5c64f71e0 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/20.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/21.png b/hr_biometric_attendance/static/description/assets/screenshots/21.png new file mode 100644 index 000000000..1de7d03ed Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/21.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/3.png b/hr_biometric_attendance/static/description/assets/screenshots/3.png new file mode 100644 index 000000000..678f8f309 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/3.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/4.png b/hr_biometric_attendance/static/description/assets/screenshots/4.png new file mode 100644 index 000000000..d97b16b65 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/4.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/5.png b/hr_biometric_attendance/static/description/assets/screenshots/5.png new file mode 100644 index 000000000..90d15d293 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/5.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/7.png b/hr_biometric_attendance/static/description/assets/screenshots/7.png new file mode 100644 index 000000000..f71003984 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/7.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/8.png b/hr_biometric_attendance/static/description/assets/screenshots/8.png new file mode 100644 index 000000000..ab51fd12c Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/8.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/9.png b/hr_biometric_attendance/static/description/assets/screenshots/9.png new file mode 100644 index 000000000..2a514a0c3 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/9.png differ diff --git a/hr_biometric_attendance/static/description/assets/screenshots/hero.gif b/hr_biometric_attendance/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..c040066e0 Binary files /dev/null and b/hr_biometric_attendance/static/description/assets/screenshots/hero.gif differ diff --git a/hr_biometric_attendance/static/description/banner.png b/hr_biometric_attendance/static/description/banner.png new file mode 100644 index 000000000..f75ed445a Binary files /dev/null and b/hr_biometric_attendance/static/description/banner.png differ diff --git a/hr_biometric_attendance/static/description/icon.png b/hr_biometric_attendance/static/description/icon.png new file mode 100644 index 000000000..9e9ae26a0 Binary files /dev/null and b/hr_biometric_attendance/static/description/icon.png differ diff --git a/hr_biometric_attendance/static/description/index.html b/hr_biometric_attendance/static/description/index.html new file mode 100644 index 000000000..189667de1 --- /dev/null +++ b/hr_biometric_attendance/static/description/index.html @@ -0,0 +1,1274 @@ + + + + + + + + + Document + + + + + + + + +
+ +
+
+

+ HR Biometric Device Integration +

+

+ This Module Integrates Odoo Employee Management with Biometric + Device.

+
+ +
+ +
+ + + +
+
+ +
+ + + +
+
+

+ KEY HIGHLIGHTS +

+
+
+
+
+ +
+
+

+ Live Capture

+

+ Real-time Data Fetching from Biometric Device to Odoo .

+
+
+
+
+
+
+ +
+
+

+ Restart Device

+

+ Option to Restart Biometric Device in Odoo.

+
+
+
+
+
+
+ +
+
+

+ Schedule Downloads

+

+ You can schedule attendance downloads by configuring the time in the settings. +

+
+
+
+
+
+
+ +
+
+

+ User Management

+

+ You can create, update, and delete users from the biometric device, managing them through Odoo employees

+
+
+
+
+
+
+ + + +
+
+ +
+

+ Overview + + +

+

+ HR Biometric Device Integration.

+
+ +
+
+ This Odoo module facilitates seamless real-time data + synchronization between the biometric device and Odoo, + allowing you to fetch attendance logs, restart the device, + and manage user information. It supports features such as + storing employee fingerprint templates, configuring the + device's timezone, and scheduling attendance downloads. + Additionally, you can create, update, and delete biometric + device users directly from Odoo's interface, offering + comprehensive management through both Odoo employees and the + Biometric Device form. +
+ +
+
+ This module uses an external python dependency + 'pyzk'. Before + installing the module install the python + package + first. The required python package can be installed using + the + following command, +
+ pip install + pyzk +
+ +
+ +
+
+ + +
+ + + +
+
+ +
+ +
+ +
+
+
+
+

+ Screenshots + + +

+

+ HR Biometric Device Integration.

+
+ +
+

+ Biometric Device Configuration Menu. +

+

+ A new menu has been added to the Attendance Module + for configuring the Biometric Device. You can find + this option under Attendance -> Biometric + Device.

+
+ +
+
+ +
+

+ Test Connection +

+

+ You can configure the machine's IP address and port, + and then test the connection to ensure it is + working. +

+
+ +
+
+ +
+

+ Biometric Device Functionalities +

+

+ In this area, you can see buttons that provide + access to different functionalities.

+
+ +
+
+ +
+

+ Download Data. +

+

+ Clicking the Download button allows you to manually + download data from the machine. This will save the + attendance records, register employee details, and + update the device information.

+
+ +
+

+ Attendance Details +

+

+ You can see the attendance details in this area. +

+
+ +
+
+ +
+

+ Clear Data +

+

+ We can clear attendance from both device and odoo. +

+
+ +
+

+ + You can restart the device by clicking the 'Restart' + button +

+
+ +
+

+ Live Capture +

+

+ If 'Live Capture' enabled, we can get the real-time + attendance from the device. +

+
+ +
+

+ The stopwatch appears when live capturing is + enabled. You also have the option to disable live + capturing. +

+
+ +
+

+ Set Timezone of device.

+
+ +
+

+ User Management +

+

+ By clicking this button, a wizard will open to + manage users.

+
+ +
+

+ Here we can see different options for user + management.

+
+ +
+

+ By choosing 'Get all users' option , we will get all + the users from the device.

+
+ +
+

+ Here we can see all the User details. +

+
+ +
+

+ Create Biometric user from odoo. +

+
+ +
+

+ User can be deleted from both odoo and device. +

+
+ +
+
+ +
+

+ Biometric Device details in the Employee's Form. +

+ +

+ You can see the biometric device details in the HR + Settings of the Employee form. +

+
+ +
+

+ + You can configure the biometric device user details + from employee form. +

+
+ +
+

+ + If the employee is already a device user, here we + can update and delete.Else we can create the user + from here. +

+
+ +
+

+ Schedule Downloads +

+

+ In the settings, you can set up a schedule for + automatic attendance downloads and configure the + time interval and period for these downloads +

+
+ +
+
+
+
+ +
+
+
+

+

+
+

+ FEATURES + + +

+

+ Comprehensive Features of Hr Biometric Device + Integration

+
+
+
+
+
+
+ + + +
+ Real-time Data Fetching from + Biometric Device to Odoo +
+
+
+
+
+
+
+
+
+ + + +
+ Option to Restart Biometric + Device in Odoo +
+
+
+
+
+
+
+
+
+ + + +
+ Option to Maintain Biometric + Device Attendance Logs in + Odoo
+
+
+
+
+
+
+
+
+ + + +
+ Downloads and save Machine + Information +
+
+
+
+
+ +
+
+
+
+ + + +
+ Set Device's timezone as the + Odoo user Time zone. +
+
+
+
+
+ +
+
+
+
+ + + +
+ You can schedule attendance + downloads by configuring the + time in the settings. +
+
+
+
+
+
+
+
+
+ + + +
+ You can create, update, and + delete users from the biometric + device, managing them through + Odoo employees.Also you can + manage it from the Biometric + Device form. +
+
+
+
+
+
+
+
+
+ + + +
+ This module support with the + following machines :
+ * uFace202 (ZKteco)
+ * iFace990 (ZKteco)
+
+
+
+
+
+
+
+
+
+ + + +
+ -Clients have reported that the + module works well with the + following machine :
+ * K40 Pro (ZKteco)
+ * SFace900 (ZKteco)
+ * FR1500 (ZKteco)
+ * UA760 (ZKteco)
+ * MB10 (ZKteco)
+
+
+
+
+
+ +
+
+
+
+
+
+
+

+ RELEASE NOTES + + +

+
+
+
+
+
+

Version 17.0.1 I Released + on : 25th July 2024 +

+

Initial commit for + hr_biometric_attendance

+
+ +
+
+
+
+ + +
+ +
+
+ + + + +
+
+
+

Related Modules

+

Explore our related modules

+
+
+
+ +
+
+ +
+ +
+ +
+
+ +
+

+ Our Services +

+
+ +
+
+
+
+ +
+
+ Odoo + Customization
+
+
+
+ +
+
+ Odoo + Implementation
+
+
+
+ +
+
+ Odoo + Support
+
+
+
+ +
+
+ Hire + Odoo + Developer
+
+
+
+ +
+
+ Odoo + Integration
+
+
+
+ +
+
+ Odoo + Migration
+
+
+
+ +
+
+ Odoo + Consultancy
+
+
+
+ +
+
+ Odoo + Implementation
+
+
+
+ +
+
+ Odoo + Licensing Consultancy
+
+
+
+ + +
+ + +
+
+
+

Our Industries

+
+
+
+
+ +
+ Trading +
+

+ Easily procure + and + sell your products

+
+
+
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

+
+
+
+
+ + + + +
+
+
+

Support

+

Need help? Get in touch. +

+
+
+
+
+
+ +
+
+

Need Help?

+

Got questions or need help? + Get + in touch.

+ +

+ odoo@cybrosys.com

+
+
+
+
+
+
+
+ +
+
+

WhatsApp

+

Say hi to us on + WhatsApp!

+ +

+91 + 86068 + 27707

+
+
+
+
+ + +
+
+
+ +
+
+

Skype

+

Say hi to us on Skype!

+ +

cybroopenerp +

+
+
+
+
+ + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ + + + + + + \ No newline at end of file diff --git a/hr_biometric_attendance/static/src/js/stopwatch.js b/hr_biometric_attendance/static/src/js/stopwatch.js new file mode 100644 index 000000000..f0c66a99f --- /dev/null +++ b/hr_biometric_attendance/static/src/js/stopwatch.js @@ -0,0 +1,62 @@ +/** @odoo-module **/ +import { registry } from '@web/core/registry'; +import { parseFloatTime } from '@web/views/fields/parsers'; +import { useInputField } from '@web/views/fields/input_field_hook'; +import { Component, useState, onMounted } from '@odoo/owl'; + +// Function to format minutes into HH:MM:SS format +function formatMinutes(value) { + if (value === false) { + return ""; + } + const isNegative = value < 0; + if (isNegative) { + value = Math.abs(value); + } + let hours = Math.floor(value / 60); + let minutes = Math.floor(value % 60); + let seconds = Math.floor((value % 1) * 60); + seconds = `${seconds}`.padStart(2, "0"); + minutes = `${minutes}`.padStart(2, "0"); + return `${isNegative ? "-" : ""}${hours}:${minutes}:${seconds}`; +} +export class StopWatch extends Component { + static template = "StopwatchTemplate"; + setup() { + this.state = useState({ + stopwatch: 0, + livecapture: this.props.record.data.is_live_capture + }); + + useInputField({ + getValue: () => this.durationFormatted, + refName: "numpadDecimal", + parse: (v) => parseFloatTime(v), + }); + + onMounted(async () => { + if (this.state.livecapture) { + const datetimeObj = new Date(this.props.record.data.live_capture_start_time); + const now = new Date(); + const timeDiff = now - datetimeObj; + this.state.stopwatch = timeDiff / 1000 / 60; + this._runTimer(); + } + }); + } + get durationFormatted() { + return formatMinutes(this.state.stopwatch); + } + _runTimer() { + if (!this.state.livecapture) { + clearTimeout(this.timer); + return; + } + this.timer = setTimeout(async () => { + this.state.stopwatch += 1 / 60; + this._runTimer(); + }, 1000); + } +} +registry.category("fields").add("stopwatch", StopWatch); +registry.category("formatters").add("stopwatch", formatMinutes); diff --git a/hr_biometric_attendance/static/src/xml/stopwatch_view.xml b/hr_biometric_attendance/static/src/xml/stopwatch_view.xml new file mode 100644 index 000000000..86882b956 --- /dev/null +++ b/hr_biometric_attendance/static/src/xml/stopwatch_view.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/hr_biometric_attendance/views/biometric_device_attendance_menus.xml b/hr_biometric_attendance/views/biometric_device_attendance_menus.xml new file mode 100644 index 000000000..de1cb7084 --- /dev/null +++ b/hr_biometric_attendance/views/biometric_device_attendance_menus.xml @@ -0,0 +1,16 @@ + + + + + + + diff --git a/hr_biometric_attendance/views/biometric_device_details_views.xml b/hr_biometric_attendance/views/biometric_device_details_views.xml new file mode 100644 index 000000000..c018db8e5 --- /dev/null +++ b/hr_biometric_attendance/views/biometric_device_details_views.xml @@ -0,0 +1,88 @@ + + + + + biometric.device.details.view.tree + biometric.device.details + + + + + + + + + + + biometric.device.details.view.form + biometric.device.details + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + +
+
+ + + +
+ +
+
+ + + Biometric Device + biometric.device.details + tree,form + +
diff --git a/hr_biometric_attendance/views/daily_attendance_views.xml b/hr_biometric_attendance/views/daily_attendance_views.xml new file mode 100644 index 000000000..523e04940 --- /dev/null +++ b/hr_biometric_attendance/views/daily_attendance_views.xml @@ -0,0 +1,25 @@ + + + + + daily.attendance.view.tree + daily.attendance + + + + + + + + + + + + + + Attendance Analysis + daily.attendance + tree + {} + + diff --git a/hr_biometric_attendance/views/hr_employee_views.xml b/hr_biometric_attendance/views/hr_employee_views.xml new file mode 100644 index 000000000..fcc6da6f4 --- /dev/null +++ b/hr_biometric_attendance/views/hr_employee_views.xml @@ -0,0 +1,25 @@ + + + + + hr.employee.view.form.inherit.hr.zk.attendance + + hr.employee + + + + + + + + + + + + + + + + + diff --git a/hr_biometric_attendance/views/res_config_settings_views.xml b/hr_biometric_attendance/views/res_config_settings_views.xml new file mode 100755 index 000000000..843488385 --- /dev/null +++ b/hr_biometric_attendance/views/res_config_settings_views.xml @@ -0,0 +1,52 @@ + + + + + + res.config.settings.view.form.inherit.hr.biometric.attendance + + res.config.settings + + + +

Biometric Device

+
+
+
+ +
+
+ +
+ If Schedule Download Enabled, You will get all + the attendance and details from the Biometric + device into your Odoo +
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hr_biometric_attendance/wizards/__init__.py b/hr_biometric_attendance/wizards/__init__.py new file mode 100644 index 000000000..b276b7965 --- /dev/null +++ b/hr_biometric_attendance/wizards/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from . import employee_biometric +from . import user_management diff --git a/hr_biometric_attendance/wizards/employee_biometric.py b/hr_biometric_attendance/wizards/employee_biometric.py new file mode 100644 index 000000000..ff84fef7b --- /dev/null +++ b/hr_biometric_attendance/wizards/employee_biometric.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from odoo import api, fields, models + + +class EmployeeBiometric(models.TransientModel): + """Transient model for Biometric device options in Employee""" + _name = 'employee.biometric' + _description = 'Employee Biometric Wizard' + + handle_create = fields.Selection( + [('create_user', 'Create User')], + 'Handle Data', help='User Management', ) + handle_update_delete = fields.Selection( + [('update_user', 'Update User'), ('delete_user', 'Delete User')], + 'Handle Data', help='User Management', ) + employee_id = fields.Many2one( + 'hr.employee', string='Employee', help='Select the Employee') + is_biometric_user = fields.Boolean('Is Already User?', + help='Checking if already a user?', + compute='_compute_is_biometric_user') + biometric_device_id = fields.Many2one('biometric.device.details', + string='Biometric Device', + help='Choose Biometric Device') + + @api.depends('employee_id') + def _compute_is_biometric_user(self): + """Compute if it is already a biometric user or not""" + for record in self: + if record.employee_id.device_id: + record.is_biometric_user = True + else: + record.is_biometric_user = False + + def action_confirm_biometric_management(self): + """Go to the desired functions in biometric.device.details""" + if self.is_biometric_user: + if self.handle_update_delete == 'update_user': + self.employee_id.device_id.update_user( + employee_id=self.employee_id.id) + else: + self.employee_id.device_id.delete_user( + employee_id=self.employee_id.id, + delete_user_selection='device_only') + else: + self.employee_id.device_id = self.biometric_device_id.id + self.biometric_device_id.set_user(employee_id=self.employee_id.id) diff --git a/hr_biometric_attendance/wizards/employee_biometric_views.xml b/hr_biometric_attendance/wizards/employee_biometric_views.xml new file mode 100644 index 000000000..8ccad283f --- /dev/null +++ b/hr_biometric_attendance/wizards/employee_biometric_views.xml @@ -0,0 +1,40 @@ + + + + + Biometric Management + employee.biometric + form + new + + + + employee.biometric.view.form + employee.biometric + +
+ + + + + + + + + +
+
+
+
+
+
\ No newline at end of file diff --git a/hr_biometric_attendance/wizards/user_management.py b/hr_biometric_attendance/wizards/user_management.py new file mode 100644 index 000000000..999a01151 --- /dev/null +++ b/hr_biometric_attendance/wizards/user_management.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +################################################################################ +from odoo import api, fields, models, _ + + +class ZkUserManagement(models.TransientModel): + """Wizard for managing Employee data In Biometric Device """ + _name = 'zk.user.management' + _description = 'ZK User Management Wizard' + + manage_users = fields.Selection( + [('get_users', 'Get all Users'), ('create_user', 'Create User'), + ('update_user', 'Update User'), + ('delete_user', 'Delete User')], + 'Manage Users', help='User Management', required=True) + employee_ids = fields.Many2many('hr.employee', string='Employees', + compute='_compute_employee_ids') + employee_id = fields.Many2one( + 'hr.employee', string='Employee', help='Select the Employee', + domain="[('id', 'in', employee_ids)]") + delete_user_selection = fields.Selection( + [('device_only', 'From Device Only'), + ('both_device', 'From Both Device and Odoo')], string='Delete From', + default='device_only', help='Choose the delete option') + + @api.depends('manage_users') + def _compute_employee_ids(self): + """Compute Employees By the Selected Option""" + for record in self: + if record.manage_users == 'create_user': + record.employee_ids = self.env['hr.employee'].search( + [('device_id', '!=', + int(self.env.context.get('active_id')))]).ids + elif record.manage_users in ['delete_user', 'update_user']: + record.employee_ids = self.env['hr.employee'].search( + [('device_id', '=', + int(self.env.context.get('active_id')))]).ids + else: + record.employee_ids = False + + def action_confirm_user_management(self): + """Function to works according to the selected option""" + if self.manage_users: + if self.manage_users == 'get_users': + self.env['biometric.device.details'].browse( + int(self.env.context.get('active_id'))).get_all_users() + return { + 'name': _("ZK Users"), + 'type': 'ir.actions.act_window', + 'res_model': 'hr.employee', + 'context': {'create': False}, + 'view_mode': 'tree,form', + 'domain': [('device_id', '=', + int(self.env.context.get('active_id')))] + } + elif self.manage_users == 'create_user': + self.env['biometric.device.details'].browse( + int(self.env.context.get('active_id'))).set_user( + employee_id=self.employee_id.id) + elif self.manage_users == 'update_user': + self.env['biometric.device.details'].browse( + int(self.env.context.get('active_id'))).update_user( + employee_id=self.employee_id.id) + else: + self.env['biometric.device.details'].browse( + int(self.env.context.get('active_id'))).delete_user( + employee_id=self.employee_id.id, + delete_user_selection=self.delete_user_selection) diff --git a/hr_biometric_attendance/wizards/user_management_views.xml b/hr_biometric_attendance/wizards/user_management_views.xml new file mode 100644 index 000000000..08bc9b943 --- /dev/null +++ b/hr_biometric_attendance/wizards/user_management_views.xml @@ -0,0 +1,41 @@ + + + + + User Management + zk.user.management + form + new + + + + zk.user.management.view.form + zk.user.management + +
+ + + + + + + + + + +
+
+
+
\ No newline at end of file