Skip to content
Permalink
Browse files

[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
  • Loading branch information...
aprieels committed Sep 11, 2019
1 parent 7652846 commit 9ae9ed146fb9a4383a9b1db4e1073ca85286b89c
Showing with 3 additions and 15 deletions.
  1. +3 −15 addons/hw_drivers/drivers/PrinterDriver.py
@@ -75,7 +75,6 @@ def cups_notification_handler(message, uri, device_id, state, reason, accepting_

class PrinterDriver(Driver):
connection_type = 'printer'
status = {'status': "disconnected", 'printers': [], 'messages': []}

def __init__(self, device):
super(PrinterDriver, self).__init__(device)
@@ -88,8 +87,7 @@ def __init__(self, device):
'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 @@ def get_device_model(cls, device):

@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 @@ def action(self, data):
self.print_raw(b64decode(data['document']))

def disconnect(self):
self.remove_connected_printer()
self.update_status('disconnected', 'Printer was disconnected')
super(PrinterDriver, self).disconnect()

0 comments on commit 9ae9ed1

Please sign in to comment.
You can’t perform that action at this time.