From 947715b046ff603f8684107a80bfa2e4ee59fe03 Mon Sep 17 00:00:00 2001 From: pha-odoo Date: Wed, 24 Jul 2019 09:40:27 +0000 Subject: [PATCH] [FIX] iot: pass dict to scale action Scale action took a string as argument. It now takes a dict so parameters can be passed to action methods. closes odoo/odoo#35136 Signed-off-by: Quentin Lejeune (qle) --- addons/hw_drivers/drivers/SerialBaseDriver.py | 2 +- addons/hw_drivers/drivers/SerialScaleDriver.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/hw_drivers/drivers/SerialBaseDriver.py b/addons/hw_drivers/drivers/SerialBaseDriver.py index a355636f9a4..6253241e420 100644 --- a/addons/hw_drivers/drivers/SerialBaseDriver.py +++ b/addons/hw_drivers/drivers/SerialBaseDriver.py @@ -104,7 +104,7 @@ class SerialDriver(Driver): try: with self._device_lock: - self._actions[data]() + self._actions[data['action']](data) time.sleep(self._protocol.commandDelay) except Exception: msg = _('An error occured while performing action %s on %s') % (data, self.device_name) diff --git a/addons/hw_drivers/drivers/SerialScaleDriver.py b/addons/hw_drivers/drivers/SerialScaleDriver.py index d788b606b94..c6673656c42 100644 --- a/addons/hw_drivers/drivers/SerialScaleDriver.py +++ b/addons/hw_drivers/drivers/SerialScaleDriver.py @@ -126,33 +126,33 @@ class ScaleDriver(SerialDriver): 'stop_reading': self._stop_reading_action, }) - def _start_reading_action(self): + def _start_reading_action(self, data): """Starts asking for the scale value.""" self._is_reading = True - def _stop_reading_action(self): + def _stop_reading_action(self, data): """Stops asking for the scale value.""" self._is_reading = False - def _clear_tare_action(self): + def _clear_tare_action(self, data): """Clears the scale current tare weight.""" # if the protocol has no clear tare command, we can just tare again clearCommand = self._protocol.clearCommand or self._protocol.tareCommand self._connection.write(clearCommand + self._protocol.commandTerminator) - def _read_once_action(self): + def _read_once_action(self, data): """Reads the scale current weight value and pushes it to the frontend.""" self._read_weight() event_manager.device_changed(self) - def _set_zero_action(self): + def _set_zero_action(self, data): """Makes the weight currently applied to the scale the new zero.""" self._connection.write(self._protocol.zeroCommand + self._protocol.commandTerminator) - def _set_tare_action(self): + def _set_tare_action(self, data): """Sets the scale's current weight value as tare weight.""" self._connection.write(self._protocol.tareCommand + self._protocol.commandTerminator)