From e971326e328cf275f461a6d9333c60e1dd553eda Mon Sep 17 00:00:00 2001 From: Oscar Alvarez Date: Wed, 23 Dec 2020 12:24:47 -0500 Subject: [PATCH] Add fixes --- app/buttonpad.py | 40 +++++++++++++-- app/css/flat_button_large.css | 2 +- app/frontwindow.py | 13 ++++- app/mainwindow.py | 94 ++++++++++++++++++++++------------- app/share/table.svg | 2 +- 5 files changed, 108 insertions(+), 43 deletions(-) diff --git a/app/buttonpad.py b/app/buttonpad.py index 2daf651..d69c6da 100644 --- a/app/buttonpad.py +++ b/app/buttonpad.py @@ -10,16 +10,46 @@ DIR_SHARE = os.path.abspath(os.path.normpath(os.path.join(__file__, __all__ = ['ButtonsFunction', 'ButtonsStacked', 'ButtonsNumber'] - -def factoryIcons(): - pass +# +# def factoryIcons(): +# pass +# +# factoryIcons() -factoryIcons() +class StartButtons(QGridLayout): + + def __init__(self, parent): + super(StartButtons, self).__init__() + self.setHorizontalSpacing(1) + self.setVerticalSpacing(1) + self.parent = parent + + values = [ + ['button_start_delivery', self.tr('DELIVERY'), 'action_start_delivery', 'delivery'], + ['button_start_table', self.tr('TO TABLE'), 'action_start_sale', 'table'], + ['button_start_take_away', self.tr('TAKE AWAY'), 'action_start_sale', 'take_away'], + ['button_start_search_order', self.tr('SEARCH ORDER'), 'action_start_sale', 'search_sale'], + ] + columns = 4 + rows = 2 + name_style = 'toolbar' + + positions = [(i, j) for i in range(rows) for j in range(columns)] + for position, value in zip(positions, values): + button = CustomButton( + parent, + id=value[0], + size=parent.screen_size, + icon=get_icon(value[3]), + title=value[1], + method=value[2], + name_style=name_style + ) + self.addWidget(button, *position) class ButtonsFunction(QGridLayout): - # Function Numpad def __init__(self, parent, values=[]): super(ButtonsFunction, self).__init__() diff --git a/app/css/flat_button_large.css b/app/css/flat_button_large.css index 8792640..d3c7b67 100644 --- a/app/css/flat_button_large.css +++ b/app/css/flat_button_large.css @@ -64,7 +64,7 @@ border-style: groove; font: 15pt; background-color: white; - height: 55px; + max-height: 85px; width : 130px; border-width: 0px; } diff --git a/app/frontwindow.py b/app/frontwindow.py index 5d149a4..f95fcf0 100644 --- a/app/frontwindow.py +++ b/app/frontwindow.py @@ -20,6 +20,7 @@ from .dialogs import ( DialogTableMoneyCount, DialogGlobalDiscountTable, DeliveryPartySelected, DialogTableDeliveryParty, DialogTableSaleConsumer, SaleConsumerSelected ) +from .constants import DIALOG_REPLY_YES __all__ = ['FrontWindow', 'ClearUi'] @@ -135,6 +136,15 @@ class FrontWindow(QMainWindow): self.global_timer = 0 safe_reconnect() + def close(self): + dialog = self.dialog('confirm_exit', response=True) + response = dialog.exec_() + if response == DIALOG_REPLY_YES: + self.check_empty_sale() + if self.active_weighing and self.reader_thread: + self.reader_thread.onClose() + super(MainWindow, self).close() + def dialog(self, name, response=False): res = QuickDialog( parent=self, @@ -249,7 +259,6 @@ class FrontWindow(QMainWindow): def action_help(self): Help(self).show() - def resize_window_tablet_dev(self): self.resize(690, self.get_geometry()[1]) @@ -259,7 +268,7 @@ class FrontWindow(QMainWindow): self.Config = FastModel('sale.configuration', self.ctx) self._config, = self.Config.find([('id', '=', 1)]) self.discount_method = self._config.get('discount_pos_method') - + self.sale_automatic = self._config.get('new_sale_automatic') self._commission_activated = self.Module.find([ ('name', '=', 'commission'), ('state', '=', 'activated'), diff --git a/app/mainwindow.py b/app/mainwindow.py index 279bfb1..952d3ba 100644 --- a/app/mainwindow.py +++ b/app/mainwindow.py @@ -10,7 +10,7 @@ from collections import OrderedDict from PyQt5.QtCore import Qt, QDate from .tools import get_icon, to_float, to_numeric from PyQt5.QtWidgets import ( - QLabel, QHBoxLayout, QVBoxLayout, QWidget, QLineEdit + QLabel, QHBoxLayout, QVBoxLayout, QWidget, QLineEdit, QGridLayout ) from .frontwindow import FrontWindow from app.commons.action import Action @@ -22,15 +22,17 @@ from app.commons.model import TableModel, TableModelEdit from app.commons.menu_buttons import MenuDash from .localdb import LocalStore from .reporting import Receipt -from .buttonpad import Buttonpad, ButtonsFunction +from .buttonpad import Buttonpad, ButtonsFunction, StartButtons from .states import STATES, RE_SIGN from .threads import DoInvoice from .constants import ( PATH_PRINTERS, DELTA_LOCALE, STRETCH, alignRight, alignLeft, alignCenter, - alignHCenter, alignVCenter, DIALOG_REPLY_NO, DIALOG_REPLY_YES, ZERO, + alignHCenter, alignVCenter, DIALOG_REPLY_NO, ZERO, RATE_CREDIT_LIMIT, FILE_BANNER, CONVERSION_DIGITS, MONEY, MINIMUM_DATE, ) +invoice_type = [('P', ('POS'))] + class MainWindow(FrontWindow): @@ -77,7 +79,8 @@ class MainWindow(FrontWindow): self._amount_text = '' self._sign = None self.create_dialogs() - self.create_new_sale() + if self.sale_automatic: + self.create_new_sale() if not hasattr(self, 'active_weighing'): self.active_weighing = False elif self.active_weighing is True: @@ -127,10 +130,6 @@ class MainWindow(FrontWindow): now = datetime.now() self.store.set_config_sync(str(now)) - def event(self, evento): - event_type = super(MainWindow, self).event(evento) - return event_type - def set_printers_usb(self, PATH_PRINTERS): for usb_dev in os.listdir(PATH_PRINTERS): if 'lp' not in usb_dev: @@ -153,15 +152,6 @@ class MainWindow(FrontWindow): and sale['state'] == 'draft' and not sale['number']: self.delete_current_sale() - def close(self): - dialog = self.dialog('confirm_exit', response=True) - response = dialog.exec_() - if response == DIALOG_REPLY_YES: - self.check_empty_sale() - if self.active_weighing and self.reader_thread: - self.reader_thread.onClose() - super(MainWindow, self).close() - def delete_current_sale(self): if self._sale['id']: self.Sale.cancel_sale(self._sale['id']) @@ -252,6 +242,24 @@ class MainWindow(FrontWindow): left_head = QHBoxLayout() left_invoice = QHBoxLayout() + board = QVBoxLayout() + + # CREATE START FRONT + self.start_front = QWidget() + start_front = StartButtons(self) + self.start_front.setLayout(start_front) + + # CREATE ORDER FRONT + self.order_front = QWidget() + vbox_order_front = QVBoxLayout() + vbox_order_front.addLayout(left_head) + vbox_order_front.addLayout(left_invoice) + self.order_front.setLayout(vbox_order_front) + + # CONFIGURE BOARD + board.addWidget(self.start_front) + board.addWidget(self.order_front) + # LEFT HEAD COMPONENTS self.message_bar = MessageBar() self.field_amount = FieldNumeric(self, 'amount', {}) @@ -272,17 +280,15 @@ class MainWindow(FrontWindow): size_input = 300 self.label_input.setMaximumWidth(size_input) - invoice_type = [('P', ('POS'))] if self.shop.get('manual_authorization'): invoice_type.append(('M', 'MANUAL')) if self.shop.get('electronic_authorization'): invoice_type.append(('1', ('VENTA ELECTRONICA'))) - self.field_invoice_type = ComboBox( - self, 'invoice_type', { - 'values': invoice_type, - 'on_change': 'action_invoice_type_selection_changed' - }) + self.field_invoice_type = ComboBox(self, 'invoice_type', { + 'values': invoice_type, + 'on_change': 'action_invoice_type_selection_changed' + }) left_invoice.addWidget(self.label_input, 1) left_invoice.addWidget(self.field_invoice_type, 0) @@ -508,15 +514,17 @@ class MainWindow(FrontWindow): self.pixmap_pos = Image(self, 'pixmap_pos', FILE_BANNER) self.table_payment = TableView('table_payment', self.table_payment_lines, [250, STRETCH]) - vbox_left.addLayout(left_head, 0) - vbox_left.addLayout(left_invoice, 0) - vbox_left.addWidget(self.table_sale_lines, 1) + + vbox_order_front.addWidget(self.table_sale_lines, 1) + vbox_left.addLayout(board, 0) panel_right.addWidget(self.pixmap_pos, 0) self.grid_info = GridForm(self, OrderedDict(info_fields), col=_cols) if self.enviroment == 'restaurant': - vbox_left.addLayout(self.buttonpad.functions, 1) + self.order_front.hide() + vbox_order_front.addLayout(self.buttonpad.functions, 0) + # vbox_left.addLayout(self.buttonpad.functions, 1) vbox_left.addLayout(self.grid_info, 0) panel_right.addLayout(menu_dash, 1) panel_right.addLayout(self.grid_amounts, 0) @@ -561,6 +569,14 @@ class MainWindow(FrontWindow): logging.warning('Unknown command/text') self._clear_context(error) + def change_view_to(self, to_view): + if to_view == 'start_front': + self.order_front.hide() + self.start_front.show() + else: + self.start_front.hide() + self.order_front.show() + def action_read_weight(self): self.reader_thread.start() @@ -784,10 +800,11 @@ class MainWindow(FrontWindow): # if self.auto_print_commission and agent_id: # self.print_equivalent_invoice(self._sale['id']) - if self.type_pos_user not in ('cashier', 'order') and self._config.get('new_sale_automatic'): + self.change_view_to('start_front') + if self.sale_automatic and self.type_pos_user not in ('cashier', 'order'): self.create_new_sale() - else: - self.state_disabled() + + self.state_disabled() self.message_bar.set('system_ready') return True @@ -857,7 +874,8 @@ class MainWindow(FrontWindow): if self.type_pos_user == 'salesman': self.print_invoice(sale_id) res = self._print_order(sale_id, 'delivery') - self.create_new_sale() + if self.sale_automatic: + self.create_new_sale() return if self.type_pos_user != 'cashier': self.field_invoice_type.set_enabled(False) @@ -1216,8 +1234,8 @@ class MainWindow(FrontWindow): return if self._ask_new_sale(): self.create_new_sale() - if self.enviroment == 'restaurant': - self.wizard_new_sale() + # if self.enviroment == 'restaurant': + # self.wizard_new_sale() def wizard_new_sale(self): # self.action_position() @@ -1261,13 +1279,21 @@ class MainWindow(FrontWindow): self.field_password_for_cancel_ask.setText('') self.set_state('cancel') self.clear_right_panel() - self.create_new_sale() + if self.sale_automatic: + self.create_new_sale() def action_search_product(self): if self._state == 'cash': return self.dialog_search_products.show() + def action_start_delivery(self): + self.create_new_sale(kind='delivery') + + def action_start_sale(self): + print('Iniciando ventas ....') + self.change_view_to('order_front') + def action_search_sale(self): delta = str(datetime.now() - timedelta(2)) if self.type_pos_user == 'cashier': diff --git a/app/share/table.svg b/app/share/table.svg index 5354cfe..eee5507 100644 --- a/app/share/table.svg +++ b/app/share/table.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file