feature/odoo18 #2
|
|
@ -463,11 +463,13 @@ class BiometricDeviceDetails(models.Model):
|
||||||
"Please Check the Connection"))
|
"Please Check the Connection"))
|
||||||
|
|
||||||
def button_door_unlock(self):
|
def button_door_unlock(self):
|
||||||
|
# Loop through device information to get IP and port
|
||||||
for info in self:
|
for info in self:
|
||||||
machine_ip = info.device_ip
|
machine_ip = info.device_ip
|
||||||
zk_port = info.port_number
|
zk_port = info.port_number
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Connecting with the device with the ip and port provided
|
# Try connecting to the device with the provided IP, port, and password
|
||||||
zk = ZK(machine_ip, port=zk_port, timeout=15,
|
zk = ZK(machine_ip, port=zk_port, timeout=15,
|
||||||
password=self.device_password,
|
password=self.device_password,
|
||||||
force_udp=False, ommit_ping=False)
|
force_udp=False, ommit_ping=False)
|
||||||
|
|
@ -477,7 +479,13 @@ class BiometricDeviceDetails(models.Model):
|
||||||
"with 'pip3 install pyzk'."))
|
"with 'pip3 install pyzk'."))
|
||||||
conn = self.device_connect(zk)
|
conn = self.device_connect(zk)
|
||||||
if conn:
|
if conn:
|
||||||
conn.unlock()
|
try:
|
||||||
|
admin_user_id = 9 # You can implement a method for this
|
||||||
|
conn.unlock(admin_user_id) # Unlock using the admin user ID
|
||||||
|
except Exception as e:
|
||||||
|
raise UserError(_("Failed to unlock door: %s") % str(e))
|
||||||
|
else:
|
||||||
|
raise UserError(_("Unable to establish a connection to the device."))
|
||||||
|
|
||||||
|
|
||||||
def get_all_users(self):
|
def get_all_users(self):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue