mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-18 23:32:02 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
30
odoo-bringout-oca-iot-iot_rule/iot_rule/models/iot_device.py
Normal file
30
odoo-bringout-oca-iot-iot_rule/iot_rule/models/iot_device.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# Copyright 2019 Creu Blanca
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import models
|
||||
|
||||
|
||||
class IotDevice(models.Model):
|
||||
_inherit = "iot.device"
|
||||
|
||||
def get_iot_keys(self, serial_of_input, type_of_key):
|
||||
iot_input = self.env["iot.device.input"].search(
|
||||
[("serial", "=", serial_of_input)], limit=1
|
||||
)
|
||||
if iot_input:
|
||||
if iot_input.lock_id:
|
||||
domain = []
|
||||
if type_of_key != "ALL":
|
||||
domain.append(("key_type", "=", type_of_key))
|
||||
return {"keys": iot_input.lock_id.get_virtual_keys(domain)}
|
||||
return {"error": "no input found"}
|
||||
|
||||
def write(self, vals):
|
||||
if vals.get("name", False):
|
||||
for device in self:
|
||||
for device_input in device.input_ids:
|
||||
if device_input.lock_id:
|
||||
input_name = device_input.name
|
||||
device_input.lock_id.write(
|
||||
{"name": vals.get("name") + " / " + input_name}
|
||||
)
|
||||
return super().write(vals)
|
||||
Loading…
Add table
Add a link
Reference in a new issue