add option for test printers

This commit is contained in:
Wilson Gomez 2023-10-25 10:29:13 -05:00
parent e4eb03b4b7
commit e4cbbd8995
11 changed files with 253 additions and 149 deletions

View File

@ -35,7 +35,7 @@ class StartButtons(QVBoxLayout):
grid.rowStretch(1)
grid.parent = parent
columns = 4
rows = 3
rows = 4
values = []
values_extend = values.extend
@ -75,7 +75,8 @@ class StartButtons(QVBoxLayout):
values_extend([
['button_help', 'AYUDA', 'action_help', 'help'],
['button_product_info', 'INFO. PRODUCTO', 'action_info_product', 'product_info']
['button_product_info', 'INFO. PRODUCTO', 'action_info_product', 'product_info'],
['button_test_print', 'TEST IMPRESION', 'action_test_print', 'test_print']
])
positions = [(i, j) for i in range(rows) for j in range(columns)]

View File

@ -132,7 +132,7 @@ class QuickDialog(QDialog):
if kind in ('info', 'error'):
self.show()
def exec_(self, args=None):
def exec(self, args=None):
res = None
res = super(QuickDialog, self).exec()
if hasattr(self, 'data_widget') and isinstance(self.data_widget, GridForm):

View File

@ -218,7 +218,7 @@ class SearchWindow(QDialog):
def execute(self):
self.current_row = None
self.filter_field.setFocus()
return self.exec_()
return self.exec()
def show(self):
self.clear_filter()

View File

@ -97,3 +97,17 @@ TYPE_VEHICLE = [
('bicycle', 'Bicycle'),
('car', 'Car'),
]
TYPE_PRINTER = [
('', ''),
('usb', 'USB'),
('network', 'RED'),
]
ROW_CHARACTERS = [
('', ''),
('28', '28'),
('33', '33'),
('42', '42'),
('48', '48'),
]

View File

@ -15,7 +15,8 @@ from PySide6.QtWidgets import (
from .proxy import Report
from .buttonpad import ButtonsFunction
from .constants import alignCenter, alignLeft, FRACTIONS, TYPE_VEHICLE, MONEY
from .constants import (alignCenter, alignLeft, FRACTIONS, TYPE_VEHICLE,
MONEY, TYPE_PRINTER, ROW_CHARACTERS)
from .commons.forms import FieldMoney, ComboBox, GridForm
from .commons.search_window import SearchWindow
from collections import OrderedDict
@ -25,6 +26,7 @@ from app.commons.table import TableView
from app.commons.model import TableEdit
from .commons.custom_button import CustomButton
from .tools import get_icon, get_screen
from .reporting import Receipt
__all__ = [
'ControlPanel', 'SearchSale', 'SearchParty', 'SearchProduct', 'Position',
@ -37,7 +39,7 @@ __all__ = [
'DialogCancelInvoice', 'DialogForceAssign', 'CombineProduct',
'DialogReports', 'DialogFixedDiscounts', 'DialogFixedDiscountsManual',
'DialogExpenses', 'DialogInfoProduct', 'DialogAdvance',
'DialogDeleteProduct', 'DialogCollection'
'DialogDeleteProduct', 'DialogCollection', 'DialogTestPrinter'
]
WIZARDS = {
@ -965,7 +967,7 @@ class DialogMoneyCount(QuickDialog):
def exec(self, kind):
self.kind = kind
self.exec_()
self.exec()
def set_total(self, row):
_row = self.model._data[row]
@ -1550,7 +1552,7 @@ class DialogComboProduct(QuickDialog):
if qty_req:
if not qty_add or int(qty_req) - int(qty_add) > 0:
dialog = self.parent.dialog('qty_combo_min_req', extra_message=f"cantidad minima {qty_req} has agregado {qty_add}")
dialog.exec_()
dialog.exec()
return False
return True
@ -1582,12 +1584,12 @@ class DialogSplitSale(QuickDialog):
msg = 'DESEA CREAR UN PEDIDO CON LOS PRODUCTOS SELECCIONADOS?'
self.label.setText(msg)
self.label_number.setText('')
return self.exec_()
return self.exec()
def info(self, number):
self.label.setText('PEDIDO CREADO EXITOSAMENTE!')
self.label_number.setText(number)
self.exec_()
self.exec()
class Help(HelpDialog):
@ -1629,6 +1631,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 DialogInfoProduct(QuickDialog):
def __init__(self, parent):
self._parent = parent
@ -1710,16 +1834,7 @@ class DialogInfoProduct(QuickDialog):
])
if self.parent._onebarcode_activated:
domain.append(('barcode', 'ilike', '%' + filter + '%'))
# if self._parent.cache_local:
# clause = [
# 'OR',
# ('barcode', 'ilike', '%{:}%'.format(filter)),
# ('code', 'ilike', '%{:}%'.format(filter)),
# ('code', 'ilike', '%{:}%'.format(filter)),
# ]
# domain = [clause]
# products = self._parent.local_db.find_product_elastic(domain, limit=100)
# else:
products = self._parent.Product.find(domain, ctx=self._parent.stock_context,
fields=['name', 'code', 'description',
'id', 'list_price',

View File

@ -20,7 +20,7 @@ from .dialogs import (
DialogDeliveryParty, TipAmount, DeliveryAmount, DialogSalesmanCode,
DialogFixedDiscounts, DialogFixedDiscountsManual, DialogComboProduct,
DialogSplitSale, DialogExpenses, DialogInfoProduct, DialogAdvance,
DialogDeleteProduct, DialogCollection
DialogDeleteProduct, DialogCollection, DialogTestPrinter,
)
from .constants import DIALOG_REPLY_YES
from .version import __version__
@ -105,7 +105,7 @@ class FrontWindow(QMainWindow):
def closeEvent(self, event):
dialog = self.dialog('confirm_exit', response=True)
response = dialog.exec_()
response = dialog.exec()
if response == DIALOG_REPLY_YES:
# self.check_empty_sale() This function cancels sale if it has not number
logout(self.ctx)
@ -167,6 +167,7 @@ class FrontWindow(QMainWindow):
self.dialog_split_sale = DialogSplitSale(self)
self.dialog_expenses = DialogExpenses(self)
self.dialog_info_product = DialogInfoProduct(self)
self.dialog_test_printer = DialogTestPrinter(self)
if self._commission_activated:
self.dialog_agent = DialogAgent(self)
if self.environment == 'restaurant' and self._sale_pos_restaurant:

View File

@ -72,7 +72,7 @@ class AppWindow(FrontWindow):
response = self.load_modules()
if response is not True:
d = self.dialog(response)
d.exec_()
d.exec()
super(AppWindow, self).close()
return
self.setup_sale_line()
@ -134,7 +134,6 @@ class AppWindow(FrontWindow):
orders = []
tasks = []
version = compare_versions(self.modules['sale_pos_frontend_rest']['version'], '6.0.7')
print('pasa por esta new query')
if version in ('equal', 'higher'):
if self.tasks_station:
result = self.SaleLine.get_data_command_and_task(args)
@ -150,10 +149,7 @@ class AppWindow(FrontWindow):
for record in records:
orders += record['orders'].values()
tasks += record['tasks'].values()
# print('ingresa a impresion orders')
# pprint(orders)
# print('ingresa a impresion tasks')
# pprint(tasks)
try:
result = self.receipt_order.print_orders(orders)
if result:
@ -165,7 +161,6 @@ class AppWindow(FrontWindow):
receipt = Receipt(context={}, environment='restaurant')
result_print = receipt.print_tasks(tasks)
if any(result_print):
print(result_print, 'validate print')
self.SaleLine.mark_tasks_printed({'task_ids': result_print})
except Exception:
traceback.print_exc()
@ -173,41 +168,6 @@ class AppWindow(FrontWindow):
# timer.singleShot(30000, self.verify_print_order_automatic)
# self.verify_command_order_th.exit(0)
# def set_domains(self):
# self.domain_search_product = [
# ('code', '!=', None),
# ('active', '=', True),
# ('template.salable', '=', True),
# ('template.account_category', '!=', None),
# ]
# if self.shop['product_categories.']:
# self.domain_search_product.append(
# ('account_category', 'in', self.shop['product_categories.'])
# )
# def set_cache_company(self):
# self.local_db = LocalDB()
# self.local_db.create_table_config()
# self._local_config = self.local_db.get_config()
# if not self._local_config:
# company_id = self.company
# self._local_config = self.local_db.set_config([company_id])
# def set_cache_products(self):
# self.local_db.create_table_product()
# local_products = self.local_db.get_local_products()
# config = self.local_db.get_config()
# _sync_date = config[1]
# products = self.Product.sync_get_products({
# 'write_date': _sync_date,
# 'shop_id': self.ctx['shop']
# })
# self.local_db.update_products(products, local_products)
# now = datetime.now()
# self.local_db.set_config_sync(str(now))
def set_printers_usb(self, PATH_PRINTERS):
for usb_dev in os.listdir(PATH_PRINTERS):
# # fix me return for set printer default usb
@ -303,7 +263,7 @@ class AppWindow(FrontWindow):
msg = 'Agente: ' + result.get('agent.').get('rec_name') + \
"\n Comision: " + str(result['commission']) + "%"
dialog = self.dialog('confirm_agent', response=True, widgets=[], extra_message=msg)
response = dialog.exec_()
response = dialog.exec()
if response == DIALOG_REPLY_NO:
self.Sale.write([sale_id], {'state': 'draft'})
return
@ -891,8 +851,8 @@ class AppWindow(FrontWindow):
if hasattr(self, 'field_list_price') and self._config.get('use_price_list'):
ctx = {'price_list': self.field_list_price.get_id()}
rec = self.SaleLine.faster_set_quantity(args, ctx=ctx)
except Exception as e:
print(e)
except Exception:
logger.exception('Error al procesar cantidad de linea producto')
return self.message_bar.set('quantity_not_valid')
self.message_bar.set('system_ready')
@ -1119,7 +1079,7 @@ class AppWindow(FrontWindow):
sales = self.Sale.find(dom, fields=_SALE_HISTORIC, limit=10)
for record in sales:
self.model_sale_historic.add_record(record)
self.dialog_historic_sales.exec_()
self.dialog_historic_sales.exec()
def check_all_commanded(self):
return all([
@ -1214,11 +1174,11 @@ class AppWindow(FrontWindow):
def action_tables(self):
if self.environment == 'restaurant':
self.dialog_manage_tables.open_tables()
self.dialog_manage_tables.exec_()
self.dialog_manage_tables.exec()
def action_release_table(self, table_id):
dialog = self.dialog('release_table', response=True)
response = dialog.exec_()
response = dialog.exec()
if response == DIALOG_REPLY_NO:
return
to_drop = {'state': 'available', 'sale': None}
@ -1248,7 +1208,7 @@ class AppWindow(FrontWindow):
value = int((self._config['tip_rate'] / 100) * total_amount)
self.field_tip_amount_ask.setText(str(value))
result = self.dialog_tip_amount.exec_()
result = self.dialog_tip_amount.exec()
if result == 0:
self.field_tip_amount_invoice.setChecked(False)
return
@ -1268,7 +1228,7 @@ class AppWindow(FrontWindow):
def action_delivery(self):
if self._state in ['finished']:
return
result = self.dialog_delivery_amount.exec_()
result = self.dialog_delivery_amount.exec()
if result == 0:
self.field_delivery_amount_invoice.setChecked(False)
return
@ -1288,7 +1248,7 @@ class AppWindow(FrontWindow):
def action_salesman_code(self):
if self._state in ['checkout']:
return
result = self.dialog_salesman_code.exec_()
result = self.dialog_salesman_code.exec()
code = self.field_salesman_code_ask.text()
if result == 0:
# Cancelled the action
@ -1302,17 +1262,17 @@ class AppWindow(FrontWindow):
return salesman_list[0]
def action_delivery_party(self):
self.dialog_delivery_party.exec_()
self.dialog_delivery_party.exec()
def action_delivery_party_panel(self):
self.dialog_control_panel.close()
self.dialog_table_delivery_party.exec_()
self.dialog_table_delivery_party.exec()
def action_control_panel(self):
self.dialog_control_panel.exec_()
self.dialog_control_panel.exec()
def action_reports(self):
self.dialog_reports.exec_()
self.dialog_reports.exec()
def dialog_money_count_accepted(self):
return True
@ -1426,16 +1386,16 @@ class AppWindow(FrontWindow):
self.set_amounts()
def action_table_discount(self):
self.dialog_auth_discount.exec_()
self.dialog_auth_discount.exec()
def action_tax(self):
self.dialog_tax.exec_()
self.dialog_tax.exec()
def button_payment_pressed(self):
if self._state not in ('checkout', 'payment'):
self.dialog('add_payment_sale_draft')
return
self.dialog_payment.exec_()
self.dialog_payment.exec()
def _check_credit_capacity(self, party):
if party['credit_limit_amount']:
@ -1526,12 +1486,12 @@ class AppWindow(FrontWindow):
self.load_sale(sale_id)
if sale.get('state') == 'quotation':
self.dialog_payment.exec_()
self.dialog_payment.exec()
flag = True
# dialog_advance.addAction
while flag:
self.dialog_advance.clean()
res = self.dialog_advance.exec_()
res = self.dialog_advance.exec()
amount = self.field_amount_ask.text()
reservation = self.field_reservation_ask.isChecked()
if res == 0 or (res == 1 and amount.isdigit()):
@ -1540,7 +1500,7 @@ class AppWindow(FrontWindow):
journal = self.journal
voucher_number = None
if journal.get('require_voucher'):
res = self.dialog_voucher.exec_()
res = self.dialog_voucher.exec()
if res == 0:
self.dialog_voucher.close()
return
@ -1580,7 +1540,7 @@ class AppWindow(FrontWindow):
if number:
self.field_invoice_number_ask.setText(number)
self.field_type_ask.set_from_id(type_doc)
res = self.dialog_print_invoice.exec_()
res = self.dialog_print_invoice.exec()
if res == DIALOG_REPLY_NO:
return
number = self.field_invoice_number_ask.text()
@ -1664,18 +1624,18 @@ class AppWindow(FrontWindow):
report.open(result)
def action_comment(self):
self.dialog_comment.exec_()
self.dialog_comment.exec()
comment = self.field_comment.toPlainText()
self.store.update({'comment': comment})
def action_position(self):
self.field_position_ask.setText(self.store.get('position'))
self.dialog_position.exec_()
self.dialog_position.exec()
position = self.field_position_ask.text()
self.store.update({'position': position})
def action_agent(self):
self.dialog_agent.exec_()
self.dialog_agent.exec()
res = self.field_commission_ask.text()
commission = float(res or 0)
self.field_agent_id = self.field_agent_ask.get_id()
@ -1709,7 +1669,7 @@ class AppWindow(FrontWindow):
'cashier', 'frontend_admin'):
self.dialog('user_without_permission')
return
self.dialog_global_discount.exec_()
self.dialog_global_discount.exec()
discount = self.field_global_discount_ask.text()
if discount and discount.isdigit():
rec = {
@ -1834,7 +1794,7 @@ class AppWindow(FrontWindow):
if self.model_sale_lines.rowCount() == 0 or not sale_id:
return
res = self.dialog_order.exec_()
res = self.dialog_order.exec()
if res == DIALOG_REPLY_NO:
return False
result = None
@ -1903,7 +1863,6 @@ class AppWindow(FrontWindow):
if not reversion and ln['order_sended'] in (True, ''):
continue
pd_id = ln['product.']['id']
print(pd_id, 'njnj')
try:
printers, cat_id = self.products_printers.get(str(pd_id))
cat_id = str(cat_id[0])
@ -1973,26 +1932,23 @@ class AppWindow(FrontWindow):
data_station = self.Sale.method_instance('get_data_for_stations', self.sale_id)
receipt = Receipt(context={}, environment='restaurant')
receipt.print_tasks(data_station.values())
print(orders, 'validate')
return
# result = self.receipt_order.print_orders(orders.values(), reversion)
# lines_sended = result + lines_ids
# print(lines_sended, 'this is lines printed')
# if not reversion and lines_sended:
# for line in lines:
# if line['id'] in lines_sended:
# line['order_sended'] = '✔'
# self.model_sale_lines.update_record(line)
# self.Sale.mark_commanded({'lines_ids': lines_sended})
# return result
result = self.receipt_order.print_orders(orders.values(), reversion)
lines_sended = result + lines_ids
if not reversion and lines_sended:
for line in lines:
if line['id'] in lines_sended:
line['order_sended'] = ''
self.model_sale_lines.update_record(line)
self.Sale.mark_commanded({'lines_ids': lines_sended})
return result
def action_source(self):
if self._state != 'checkout' and self.sources:
self.dialog_source.exec_()
self.dialog_source.exec()
def action_payment_term(self):
if self._state == 'payment' or self.type_pos_user == 'salesman':
self.dialog_payment_term.exec_()
self.dialog_payment_term.exec()
def action_new_sale(self):
if self._state in ['checkout']:
@ -2011,7 +1967,7 @@ class AppWindow(FrontWindow):
def _ask_new_sale(self):
dialog = self.dialog('new_sale', response=True)
res = dialog.exec_()
res = dialog.exec()
if res == DIALOG_REPLY_NO:
return False
return True
@ -2021,7 +1977,7 @@ class AppWindow(FrontWindow):
if self._state == 'disabled':
return
if self.type_pos_user == 'cashier':
self.dialog_cancel_invoice.exec_()
self.dialog_cancel_invoice.exec()
password = self.field_password_for_cancel_ask.text()
if password != self._password_admin:
return self.dialog('not_permission_for_cancel')
@ -2034,7 +1990,7 @@ class AppWindow(FrontWindow):
sale.get('invoice_number'):
return self.dialog('not_permission_delete_sale')
dialog = self.dialog('cancel_sale', response=True)
response = dialog.exec_()
response = dialog.exec()
if response == DIALOG_REPLY_NO:
return
self.Sale.cancel_sale({'id': sale['id']})
@ -2078,7 +2034,7 @@ class AppWindow(FrontWindow):
self._sale_historic = sales
for record in sales:
self.model_sale_historic.add_record(record)
self.dialog_historic_sales.exec_()
self.dialog_historic_sales.exec()
def action_search_sale(self):
if hasattr(self, 'activate_scale_sync') and self.activate_scale_sync:
@ -2516,7 +2472,7 @@ class AppWindow(FrontWindow):
if self._state == 'payment':
dialog = self.dialog('cant_add_discount')
dialog.exec_()
dialog.exec()
return
if discount:
self.validate_discount(discount, _line)
@ -2879,7 +2835,7 @@ class AppWindow(FrontWindow):
salesman = self.store.get('salesman')
if self.salesman_required and not salesman:
dialog = self.dialog('missing_salesman')
dialog.exec_()
dialog.exec()
return False
return True
@ -2939,7 +2895,7 @@ class AppWindow(FrontWindow):
if self._password_force_assign:
if (request_qty and qty_ < request_qty) or (qty_ <= 0):
self.message_bar.set('without_stock_quantity', product['name'])
self.dialog_force_assign.exec_()
self.dialog_force_assign.exec()
password = self.field_password_force_assign_ask.text()
self.field_password_force_assign_ask.setText('')
if password != self._password_force_assign:
@ -3217,7 +3173,7 @@ class AppWindow(FrontWindow):
'cashier', 'frontend_admin'):
self.dialog('user_without_permission')
return
self.dialog_fixed_discount.exec_()
self.dialog_fixed_discount.exec()
if self.environment == 'restaurant':
self.dialog_combine_product.close()
@ -3227,7 +3183,7 @@ class AppWindow(FrontWindow):
self.dialog('user_without_permission')
return
self.field_bono_discount_manual.setText('')
self.dialog_fixed_discount_manual.exec_()
self.dialog_fixed_discount_manual.exec()
if self.environment == 'restaurant':
self.dialog_combine_product.close()
discount = self.field_bono_discount_manual.text()
@ -3264,7 +3220,7 @@ class AppWindow(FrontWindow):
if qty_min_req:
self.dialog_combo_product.label_qty_min_req.setText(str(qty_min_req))
self.dialog_combo_product.set_buttons(products_mix)
self.dialog_combo_product.exec_()
self.dialog_combo_product.exec()
self.dialog_combo_product.close()
def action_combine_line(self):
@ -3282,7 +3238,7 @@ class AppWindow(FrontWindow):
('categories', 'in', categories),
], fields=['id', 'name', 'code', 'categories', 'rec_name', 'list_price'])
self.dialog_combine_product.set_buttons(mixables)
self.dialog_combine_product.exec_()
self.dialog_combine_product.exec()
self.dialog_combine_product.filter_field.clear()
self.dialog_combine_product.close()
@ -3308,7 +3264,7 @@ class AppWindow(FrontWindow):
return self.dialog('user_without_permission')
if order_sended:
res = self.dialog_delete_product.exec_()
res = self.dialog_delete_product.exec()
if res == 0:
self.dialog_delete_product.close()
return
@ -3383,7 +3339,7 @@ class AppWindow(FrontWindow):
journal = self.journal
if journal.get('require_voucher'):
res = self.dialog_voucher.exec_()
res = self.dialog_voucher.exec()
if res == 0:
self.dialog_voucher.close()
return
@ -3753,3 +3709,6 @@ class AppWindow(FrontWindow):
self.change_view_to('order_front')
self.load_sale(sale)
self.dialog_manage_tables.hide()
def action_test_print(self):
self.dialog_test_printer.exec()

View File

@ -133,38 +133,44 @@ class Receipt(object):
return self._printer
def test_printer(self):
if self._interface == 'usb':
if OS_NAME == 'posix':
self._printer = printer.File(
self._device, profile=self._profile)
elif OS_NAME == 'nt':
self._printer = printer.Win32Raw(self._device)
self._printer.open()
elif self._interface == 'network':
try:
host, port = self._device.split(":")
except Exception:
host, port = self._device, None
if port:
self._printer = printer.Network(host, port=int(port), timeout=15)
else:
self._printer = printer.Network(host, timeout=15)
elif self._interface == 'ssh':
self._printer = FileSSH(*self._device.split('@'))
self._printer.open()
if not self._printer:
return
self.print_enter()
try:
self._printer.image(image_test_file, center=True)
except Exception as e:
print(e, 'error')
self.print_enter()
self.print_header()
self._printer.ln(3)
self._printer.cut()
self._printer.cashdraw(2)
self._printer.close()
if self._interface == 'usb':
if OS_NAME == 'posix':
self._printer = printer.File(
self._device, profile=self._profile)
elif OS_NAME == 'nt':
self._printer = printer.Win32Raw(self._device)
self._printer.open()
elif self._interface == 'network':
try:
host, port = self._device.split(":")
except Exception:
host, port = self._device, None
if port:
self._printer = printer.Network(host, port=int(port), timeout=15)
else:
self._printer = printer.Network(host, timeout=15)
elif self._interface == 'ssh':
self._printer = FileSSH(*self._device.split('@'))
self._printer.open()
if not self._printer:
return
self.print_enter()
try:
self._printer.image(image_test_file, center=True)
except Exception as e:
print(e, 'error')
self.print_enter()
self.print_header()
self._printer.ln(3)
self._printer.cut()
self._printer.cashdraw(2)
self._printer.close()
result = True
except Exception:
logging.exception(f'Error test impresion; interface: {self._interface} device: {self._device}')
result = False
return result
# self._printer.beep()
def config_printer(self, printer):

7
app/share/test_print.svg Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Svg Vector Icons : http://www.onlinewebfonts.com/icon -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="25px" y="25px" viewBox="0 0 256 256" enable-background="new 0 0 256 256" xml:space="preserve">
<metadata> Svg Vector Icons : http://www.onlinewebfonts.com/icon </metadata>
<g><g><g><path fill="#000000" d="M110.9,11.2c-40.7,6.2-75.2,32.7-91.4,70.2c-23,53.5-3.3,115.8,46.4,146.9c5.2,3.3,16.5,8.8,22.1,10.8c6.2,2.2,17.1,4.8,24,5.8c8.6,1.2,23.7,1.2,32.1-0.1c25.9-3.7,49.2-15.4,67.5-33.7c39.5-39.7,45.7-102,14.8-148.3c-16.8-25.1-42.2-42.8-71.1-49.7C142,10,124,9.2,110.9,11.2z M142,22.5c44.6,5.8,81.1,39.8,90.2,83.8c6.2,29.8-0.8,61.1-19.1,85.5c-3.9,5.2-13,14.6-18,18.7c-15,12.1-32.7,19.9-51.9,22.8c-7.7,1.2-22.3,1.2-30,0c-23.3-3.5-43.8-13.8-60.3-30.3c-32-32.1-40.3-81-20.4-121.5C38,70.2,43.6,62.4,52.6,53.2C69,36.6,90.1,26,113.6,22.5C120.2,21.6,134.6,21.6,142,22.5z"/><path fill="#000000" d="M92.7,75.1c-1.5,0.8-2.8,2.1-3.9,3.8c-1.5,2.4-1.6,2.8-1.7,9.5l-0.2,7l-5.7,0.3c-7.2,0.4-9.9,1.5-12.3,5.4l-1.6,2.5L67.1,130c-0.2,29.1-0.1,30.7,2.7,33.9c2.7,3.1,5,3.8,11.6,3.8H87v10.4c0,6,0.3,11.3,0.6,12.5c0.8,2.7,4.3,6.3,7.1,7.1c3,0.8,64.2,0.8,66.7,0c2.8-0.9,5.2-3.1,6.3-5.4c0.8-1.9,1-3.6,1-13.3v-11.1l6.5-0.2c6.3-0.2,6.6-0.2,8.8-1.7c1.2-0.9,2.8-2.6,3.5-3.9l1.2-2.3v-27.7c0-27.8,0-27.8-1.2-30.1c-2.4-4.7-6.3-6.3-15-6.3h-3.8v-6.9c0-7.4-0.5-9.4-3.3-12c-3-2.8-2.5-2.8-37.7-2.8H95.1L92.7,75.1z M160.1,82.5c0.9,0.9,0.9,33.1,0,34c-0.5,0.5-8.4,0.6-32.4,0.6c-30.8,0-31.8-0.1-32.3-1c-0.7-1.4-0.7-31.9,0-33.3c0.5-0.9,1.5-1,32.3-1C151.8,81.8,159.7,82,160.1,82.5z M159.8,157.2c0.9,0.5,1,1.3,1,16.2c0,11.5-0.2,15.9-0.6,16.3c-0.5,0.5-8.3,0.6-32.1,0.6c-27.9,0-31.6-0.1-32.3-0.8c-0.7-0.7-0.8-2.9-0.8-16c0-15.1,0-15.2,1.2-16c1.1-0.7,5-0.8,31.9-0.8C148.2,156.7,159.1,156.9,159.8,157.2z"/><path fill="#000000" d="M103.9,167.2v3.7h24.2h24.2v-3.7v-3.7h-24.2h-24.2V167.2z"/><path fill="#000000" d="M103.9,181.2v4h24.2h24.2v-4v-4h-24.2h-24.2V181.2z"/></g></g></g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -69,5 +69,6 @@ class StackMessages(QWidget):
'confirm_agent': ('question', 'Confirmar comision de agente'),
'qty_combo_min_req': ('error', 'Cantidad minima requerida!'),
'error_server': ('error', 'Error'),
'print_error': ('error', 'Error de Impresión')
'print_error': ('error', 'Error de Impresión'),
'test_printer': ('error', 'Resultado Test: ')
}

0
tests/__init__.py Normal file
View File