oca-ocb-hw/odoo-bringout-oca-iot-iot_rule/iot_rule/models/iot_device_input.py
Ernad Husremovic b1d16a46bf Move 7 IoT modules to oca-ocb-hw and 9 product modules to oca-product
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 17:53:33 +02:00

29 lines
849 B
Python

# Copyright 2019 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class IotDeviceInput(models.Model):
_inherit = "iot.device.input"
lock_id = fields.Many2one("iot.lock")
def call_lock(self, value):
result = self.lock_id.check_access_unique_virtual_key(value)
return {"access_granted": result}
def get_iot_keys(self, domain=None):
if domain is None:
domain = []
return {"keys": self.lock_id.get_virtual_keys(domain)}
def generate_iot_lock(self):
self.ensure_one()
if not self.lock_id:
device_name = self.device_id.name
lock = self.env["iot.lock"].create(
{"name": device_name + " / " + self.name}
)
self.lock_id = lock.id
return {}