add option for test printers
This commit is contained in:
parent
e4cbbd8995
commit
d735ffccde
126
app/dialogs.py
126
app/dialogs.py
|
@ -15,6 +15,8 @@ from PySide6.QtWidgets import (
|
|||
|
||||
from .proxy import Report
|
||||
from .buttonpad import ButtonsFunction
|
||||
from .constants import (alignCenter, alignLeft, FRACTIONS, TYPE_VEHICLE,
|
||||
MONEY, TYPE_PRINTER, ROW_CHARACTERS)
|
||||
from .constants import (alignCenter, alignLeft, FRACTIONS, TYPE_VEHICLE,
|
||||
MONEY, TYPE_PRINTER, ROW_CHARACTERS)
|
||||
from .commons.forms import FieldMoney, ComboBox, GridForm
|
||||
|
@ -27,6 +29,7 @@ from app.commons.model import TableEdit
|
|||
from .commons.custom_button import CustomButton
|
||||
from .tools import get_icon, get_screen
|
||||
from .reporting import Receipt
|
||||
from .reporting import Receipt
|
||||
|
||||
__all__ = [
|
||||
'ControlPanel', 'SearchSale', 'SearchParty', 'SearchProduct', 'Position',
|
||||
|
@ -1631,6 +1634,128 @@ class DialogListProduct(QuickDialog):
|
|||
grid.addWidget(self.input_code, 1, 2)
|
||||
|
||||
|
||||
class DialogTestPrinter(QuickDialog):
|
||||
|
||||
def __init__(self, parent):
|
||||
self._parent = parent
|
||||
width, height = get_screen()
|
||||
grid = QGridLayout()
|
||||
if parent.environment == 'restaurant':
|
||||
_sizes = (100, 210, 210, 100)
|
||||
fields = (
|
||||
{'name': 'id', 'label': 'ID', 'type': 'integer', 'invisible': True},
|
||||
{'name': 'name', 'label': 'NOMBRE', 'type': 'char', 'readonly': True},
|
||||
{'name': 'interface', 'label': 'INTERFACE', 'type': 'char', 'readonly': True},
|
||||
{'name': 'server', 'label': 'SERVIDOR', 'type': 'char', 'readonly': True},
|
||||
{'name': 'row_characters', 'label': 'CARACTERES POR FILA', 'type': 'integer', 'readonly': True},
|
||||
)
|
||||
self.model = TableEdit(self, [], fields)
|
||||
self.table = TableView('model_printers', self.model, _sizes, self.fill_fields)
|
||||
self.table.hideColumn(0)
|
||||
|
||||
grid.addWidget(self.table, 0, 0, 2, 7)
|
||||
|
||||
label_interface = QLabel('INTERFACE:')
|
||||
label_interface.setObjectName('label_interface')
|
||||
grid.addWidget(label_interface, 3, 1)
|
||||
self.combo_interface = ComboBox(parent, 'type_printer', {'values': TYPE_PRINTER})
|
||||
grid.addWidget(self.combo_interface, 3, 2)
|
||||
|
||||
label_server = QLabel('SERVIDOR:')
|
||||
label_server.setObjectName('label_server')
|
||||
grid.addWidget(label_server, 3, 3)
|
||||
self.input_server = QLineEdit()
|
||||
self.input_server.setObjectName('input_server')
|
||||
grid.addWidget(self.input_server, 3, 4)
|
||||
|
||||
label_row_characters = QLabel('CARACTERES POR FILA:')
|
||||
label_row_characters.setObjectName('label_row_characters')
|
||||
grid.addWidget(label_row_characters, 3, 5)
|
||||
self.combo_row_characters = ComboBox(
|
||||
parent, 'row_characters', {'values': ROW_CHARACTERS}
|
||||
)
|
||||
grid.addWidget(self.combo_row_characters, 3, 6)
|
||||
|
||||
super(DialogTestPrinter, self).__init__(
|
||||
parent, 'action', widgets=[grid]
|
||||
)
|
||||
self.setWindowTitle('TEST IMPRESORA')
|
||||
self.setFixedSize(int(width * 0.4), int(height * 0.3))
|
||||
|
||||
def load(self):
|
||||
printers_shop = self.parent.printers_shop
|
||||
if getattr(self, 'table', None) and printers_shop:
|
||||
model_add = self.model.add_record
|
||||
for k, v in printers_shop.items():
|
||||
data = [
|
||||
k,
|
||||
v.get('name', ''),
|
||||
v['interface'],
|
||||
v['host'],
|
||||
v['row_characters'],
|
||||
]
|
||||
model_add(data)
|
||||
|
||||
def exec_(self):
|
||||
self.clear()
|
||||
self.load()
|
||||
super(DialogTestPrinter, self).exec_()
|
||||
|
||||
def clear(self):
|
||||
self.model.clearData()
|
||||
self.input_server.setText("")
|
||||
self.combo_interface.set_from_id("")
|
||||
self.combo_row_characters.set_from_id("")
|
||||
|
||||
def test_printer(self):
|
||||
print('configure test')
|
||||
server = self.input_server.text()
|
||||
interface = self.combo_interface.get_id()
|
||||
row_characters = self.combo_row_characters.get_id()
|
||||
|
||||
printer_test = {
|
||||
'interface': interface,
|
||||
'device': str(server),
|
||||
'profile': 'TM-P80',
|
||||
'row_characters': row_characters,
|
||||
}
|
||||
|
||||
ctx_printing = {}
|
||||
ctx_printing['company'] = 'OSCORP INC'
|
||||
ctx_printing['sale_device'] = 'CAJA-10'
|
||||
ctx_printing['shop'] = 'Shop Wall Boulevard'
|
||||
ctx_printing['street'] = 'Cll 21 # 172-81. Central Park'
|
||||
ctx_printing['user'] = 'Charles Chapplin'
|
||||
ctx_printing['city'] = 'Dallas'
|
||||
ctx_printing['zip'] = '0876'
|
||||
ctx_printing['phone'] = '591 5513 455'
|
||||
ctx_printing['id_number'] = '123456789-0'
|
||||
ctx_printing['tax_regime'] = 'none'
|
||||
receipt = Receipt(ctx_printing)
|
||||
receipt.config_printer(printer_test)
|
||||
return receipt.test_printer()
|
||||
|
||||
def dialog_accepted(self):
|
||||
result = self.test_printer()
|
||||
if result:
|
||||
msg = 'Impresion Exitosa ✔'
|
||||
else:
|
||||
msg = '''\n\n Test de impresión ha fallado,
|
||||
es posible que haya un problema con la conexión de energía, USB o red.
|
||||
Para solucionar el problema, asegúrese de que la impresora esté conectada
|
||||
correctamente a la fuente de alimentación y que el cable USB o Ethernet
|
||||
esté conectado correctamente a la impresora y
|
||||
al dispositivo desde el que está intentando imprimir.'''
|
||||
self._parent.dialog('test_printer', extra_message=msg)
|
||||
if result:
|
||||
super(DialogTestPrinter, self).dialog_accepted()
|
||||
|
||||
def fill_fields(self, data):
|
||||
self.input_server.setText(data[3])
|
||||
self.combo_interface.set_from_id(data[2])
|
||||
self.combo_row_characters.set_from_id(str(data[4]))
|
||||
|
||||
|
||||
class DialogTestPrinter(QuickDialog):
|
||||
|
||||
def __init__(self, parent):
|
||||
|
@ -1835,6 +1960,7 @@ class DialogInfoProduct(QuickDialog):
|
|||
if self.parent._onebarcode_activated:
|
||||
domain.append(('barcode', 'ilike', '%' + filter + '%'))
|
||||
|
||||
|
||||
products = self._parent.Product.find(domain, ctx=self._parent.stock_context,
|
||||
fields=['name', 'code', 'description',
|
||||
'id', 'list_price',
|
||||
|
|
Loading…
Reference in New Issue