From 7cb540b48571cc2a6e0d8f7869b34dd0572a0c77 Mon Sep 17 00:00:00 2001 From: Antoine Prieels Date: Wed, 11 Sep 2019 06:37:11 +0000 Subject: [PATCH] [REM] hw_drivers: Remove printers list from status The status returned bby PrinterDriver contained a list of connected printers to be used in Enterprise, to determine if the printer that was selected in POS Config was used in the POS. We now read this status from the db and we therefore don't need this anymore. In Community the user only needs to know if there's a printer connected to the Box. We just have to know if any printer is present. TaskID: 1970884 --- addons/hw_drivers/drivers/PrinterDriver.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/addons/hw_drivers/drivers/PrinterDriver.py b/addons/hw_drivers/drivers/PrinterDriver.py index 9adc5db35ba..6eb21632025 100644 --- a/addons/hw_drivers/drivers/PrinterDriver.py +++ b/addons/hw_drivers/drivers/PrinterDriver.py @@ -75,7 +75,6 @@ bus.add_signal_receiver(cups_notification_handler, signal_name="PrinterStateChan class PrinterDriver(Driver): connection_type = 'printer' - status = {'status': "disconnected", 'printers': [], 'messages': []} def __init__(self, device): super(PrinterDriver, self).__init__(device) @@ -88,8 +87,7 @@ class PrinterDriver(Driver): 'reason': None, } self.send_status() - if 'direct' in self._device_connection or helpers.get_odoo_server_url(): - self.add_connected_printer() + if 'direct' in self._device_connection: self.print_status() @classmethod @@ -137,22 +135,13 @@ class PrinterDriver(Driver): @classmethod def get_status(cls): - return cls.status + status = 'connected' if any(iot_devices[d].device_type == "printer" and iot_devices[d].device_connection == 'direct' for d in iot_devices) else 'disconnected' + return {'status': status, 'messages': ''} @property def device_identifier(self): return self.dev['identifier'] - def add_connected_printer(self): - PrinterDriver.status['status'] = "connected" - PrinterDriver.status['printers'].append(self.device_identifier) - - def remove_connected_printer(self): - if self.device_identifier in PrinterDriver.status['printers']: - PrinterDriver.status['printers'].remove(self.device_identifier) - if not PrinterDriver.status['printers']: - PrinterDriver.status['status'] = "disconnected" - def action(self, data): if data.get('action') == 'cashbox': self.open_cashbox() @@ -162,7 +151,6 @@ class PrinterDriver(Driver): self.print_raw(b64decode(data['document'])) def disconnect(self): - self.remove_connected_printer() self.update_status('disconnected', 'Printer was disconnected') super(PrinterDriver, self).disconnect()