Currently it is only possible to run the modules for the IoT Box on Raspios. The modifications brought by this commit brings the possibility that the various hw_* modules can be executed whatever the OS of the hardware (Linux or Windows). If the modules should be versioned according to the OS, the file will be renamed so that the end of the file includes *_L (for linux) or *_W (for windows) closes odoo/odoo#107350 X-original-commit: b7b8809ea8b7fe4ac8b24f43fe3f3a5e38a66696 Related: odoo/enterprise#34713 Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
25 lines
762 B
Python
25 lines
762 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
import win32print
|
|
|
|
from odoo.addons.hw_drivers.interface import Interface
|
|
|
|
class PrinterInterface(Interface):
|
|
_loop_delay = 30
|
|
connection_type = 'printer'
|
|
|
|
def get_devices(self):
|
|
printer_devices = {}
|
|
printers = win32print.EnumPrinters(win32print.PRINTER_ENUM_LOCAL)
|
|
|
|
for printer in printers:
|
|
identifier = printer[2]
|
|
handle_printer = win32print.OpenPrinter(identifier)
|
|
win32print.GetPrinter(handle_printer, 2)
|
|
printer_devices[identifier] = {
|
|
'identifier': identifier,
|
|
'printer_handle': handle_printer,
|
|
}
|
|
return printer_devices
|