Add fixes

This commit is contained in:
Oscar Alvarez 2020-12-23 12:24:47 -05:00
parent c143ab440a
commit e971326e32
5 changed files with 108 additions and 43 deletions

View File

@ -10,16 +10,46 @@ DIR_SHARE = os.path.abspath(os.path.normpath(os.path.join(__file__,
__all__ = ['ButtonsFunction', 'ButtonsStacked', 'ButtonsNumber'] __all__ = ['ButtonsFunction', 'ButtonsStacked', 'ButtonsNumber']
#
def factoryIcons(): # def factoryIcons():
pass # 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): class ButtonsFunction(QGridLayout):
# Function Numpad
def __init__(self, parent, values=[]): def __init__(self, parent, values=[]):
super(ButtonsFunction, self).__init__() super(ButtonsFunction, self).__init__()

View File

@ -64,7 +64,7 @@
border-style: groove; border-style: groove;
font: 15pt; font: 15pt;
background-color: white; background-color: white;
height: 55px; max-height: 85px;
width : 130px; width : 130px;
border-width: 0px; border-width: 0px;
} }

View File

@ -20,6 +20,7 @@ from .dialogs import (
DialogTableMoneyCount, DialogGlobalDiscountTable, DeliveryPartySelected, DialogTableMoneyCount, DialogGlobalDiscountTable, DeliveryPartySelected,
DialogTableDeliveryParty, DialogTableSaleConsumer, SaleConsumerSelected DialogTableDeliveryParty, DialogTableSaleConsumer, SaleConsumerSelected
) )
from .constants import DIALOG_REPLY_YES
__all__ = ['FrontWindow', 'ClearUi'] __all__ = ['FrontWindow', 'ClearUi']
@ -135,6 +136,15 @@ class FrontWindow(QMainWindow):
self.global_timer = 0 self.global_timer = 0
safe_reconnect() 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): def dialog(self, name, response=False):
res = QuickDialog( res = QuickDialog(
parent=self, parent=self,
@ -249,7 +259,6 @@ class FrontWindow(QMainWindow):
def action_help(self): def action_help(self):
Help(self).show() Help(self).show()
def resize_window_tablet_dev(self): def resize_window_tablet_dev(self):
self.resize(690, self.get_geometry()[1]) self.resize(690, self.get_geometry()[1])
@ -259,7 +268,7 @@ class FrontWindow(QMainWindow):
self.Config = FastModel('sale.configuration', self.ctx) self.Config = FastModel('sale.configuration', self.ctx)
self._config, = self.Config.find([('id', '=', 1)]) self._config, = self.Config.find([('id', '=', 1)])
self.discount_method = self._config.get('discount_pos_method') self.discount_method = self._config.get('discount_pos_method')
self.sale_automatic = self._config.get('new_sale_automatic')
self._commission_activated = self.Module.find([ self._commission_activated = self.Module.find([
('name', '=', 'commission'), ('name', '=', 'commission'),
('state', '=', 'activated'), ('state', '=', 'activated'),

View File

@ -10,7 +10,7 @@ from collections import OrderedDict
from PyQt5.QtCore import Qt, QDate from PyQt5.QtCore import Qt, QDate
from .tools import get_icon, to_float, to_numeric from .tools import get_icon, to_float, to_numeric
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
QLabel, QHBoxLayout, QVBoxLayout, QWidget, QLineEdit QLabel, QHBoxLayout, QVBoxLayout, QWidget, QLineEdit, QGridLayout
) )
from .frontwindow import FrontWindow from .frontwindow import FrontWindow
from app.commons.action import Action 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 app.commons.menu_buttons import MenuDash
from .localdb import LocalStore from .localdb import LocalStore
from .reporting import Receipt from .reporting import Receipt
from .buttonpad import Buttonpad, ButtonsFunction from .buttonpad import Buttonpad, ButtonsFunction, StartButtons
from .states import STATES, RE_SIGN from .states import STATES, RE_SIGN
from .threads import DoInvoice from .threads import DoInvoice
from .constants import ( from .constants import (
PATH_PRINTERS, DELTA_LOCALE, STRETCH, alignRight, alignLeft, alignCenter, 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, RATE_CREDIT_LIMIT, FILE_BANNER, CONVERSION_DIGITS, MONEY, MINIMUM_DATE,
) )
invoice_type = [('P', ('POS'))]
class MainWindow(FrontWindow): class MainWindow(FrontWindow):
@ -77,7 +79,8 @@ class MainWindow(FrontWindow):
self._amount_text = '' self._amount_text = ''
self._sign = None self._sign = None
self.create_dialogs() self.create_dialogs()
self.create_new_sale() if self.sale_automatic:
self.create_new_sale()
if not hasattr(self, 'active_weighing'): if not hasattr(self, 'active_weighing'):
self.active_weighing = False self.active_weighing = False
elif self.active_weighing is True: elif self.active_weighing is True:
@ -127,10 +130,6 @@ class MainWindow(FrontWindow):
now = datetime.now() now = datetime.now()
self.store.set_config_sync(str(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): def set_printers_usb(self, PATH_PRINTERS):
for usb_dev in os.listdir(PATH_PRINTERS): for usb_dev in os.listdir(PATH_PRINTERS):
if 'lp' not in usb_dev: if 'lp' not in usb_dev:
@ -153,15 +152,6 @@ class MainWindow(FrontWindow):
and sale['state'] == 'draft' and not sale['number']: and sale['state'] == 'draft' and not sale['number']:
self.delete_current_sale() 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): def delete_current_sale(self):
if self._sale['id']: if self._sale['id']:
self.Sale.cancel_sale(self._sale['id']) self.Sale.cancel_sale(self._sale['id'])
@ -252,6 +242,24 @@ class MainWindow(FrontWindow):
left_head = QHBoxLayout() left_head = QHBoxLayout()
left_invoice = 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 # LEFT HEAD COMPONENTS
self.message_bar = MessageBar() self.message_bar = MessageBar()
self.field_amount = FieldNumeric(self, 'amount', {}) self.field_amount = FieldNumeric(self, 'amount', {})
@ -272,17 +280,15 @@ class MainWindow(FrontWindow):
size_input = 300 size_input = 300
self.label_input.setMaximumWidth(size_input) self.label_input.setMaximumWidth(size_input)
invoice_type = [('P', ('POS'))]
if self.shop.get('manual_authorization'): if self.shop.get('manual_authorization'):
invoice_type.append(('M', 'MANUAL')) invoice_type.append(('M', 'MANUAL'))
if self.shop.get('electronic_authorization'): if self.shop.get('electronic_authorization'):
invoice_type.append(('1', ('VENTA ELECTRONICA'))) invoice_type.append(('1', ('VENTA ELECTRONICA')))
self.field_invoice_type = ComboBox( self.field_invoice_type = ComboBox(self, 'invoice_type', {
self, 'invoice_type', { 'values': invoice_type,
'values': invoice_type, 'on_change': 'action_invoice_type_selection_changed'
'on_change': 'action_invoice_type_selection_changed' })
})
left_invoice.addWidget(self.label_input, 1) left_invoice.addWidget(self.label_input, 1)
left_invoice.addWidget(self.field_invoice_type, 0) 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.pixmap_pos = Image(self, 'pixmap_pos', FILE_BANNER)
self.table_payment = TableView('table_payment', self.table_payment = TableView('table_payment',
self.table_payment_lines, [250, STRETCH]) self.table_payment_lines, [250, STRETCH])
vbox_left.addLayout(left_head, 0)
vbox_left.addLayout(left_invoice, 0) vbox_order_front.addWidget(self.table_sale_lines, 1)
vbox_left.addWidget(self.table_sale_lines, 1) vbox_left.addLayout(board, 0)
panel_right.addWidget(self.pixmap_pos, 0) panel_right.addWidget(self.pixmap_pos, 0)
self.grid_info = GridForm(self, OrderedDict(info_fields), col=_cols) self.grid_info = GridForm(self, OrderedDict(info_fields), col=_cols)
if self.enviroment == 'restaurant': 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) vbox_left.addLayout(self.grid_info, 0)
panel_right.addLayout(menu_dash, 1) panel_right.addLayout(menu_dash, 1)
panel_right.addLayout(self.grid_amounts, 0) panel_right.addLayout(self.grid_amounts, 0)
@ -561,6 +569,14 @@ class MainWindow(FrontWindow):
logging.warning('Unknown command/text') logging.warning('Unknown command/text')
self._clear_context(error) 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): def action_read_weight(self):
self.reader_thread.start() self.reader_thread.start()
@ -784,10 +800,11 @@ class MainWindow(FrontWindow):
# if self.auto_print_commission and agent_id: # if self.auto_print_commission and agent_id:
# self.print_equivalent_invoice(self._sale['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() self.create_new_sale()
else:
self.state_disabled() self.state_disabled()
self.message_bar.set('system_ready') self.message_bar.set('system_ready')
return True return True
@ -857,7 +874,8 @@ class MainWindow(FrontWindow):
if self.type_pos_user == 'salesman': if self.type_pos_user == 'salesman':
self.print_invoice(sale_id) self.print_invoice(sale_id)
res = self._print_order(sale_id, 'delivery') res = self._print_order(sale_id, 'delivery')
self.create_new_sale() if self.sale_automatic:
self.create_new_sale()
return return
if self.type_pos_user != 'cashier': if self.type_pos_user != 'cashier':
self.field_invoice_type.set_enabled(False) self.field_invoice_type.set_enabled(False)
@ -1216,8 +1234,8 @@ class MainWindow(FrontWindow):
return return
if self._ask_new_sale(): if self._ask_new_sale():
self.create_new_sale() self.create_new_sale()
if self.enviroment == 'restaurant': # if self.enviroment == 'restaurant':
self.wizard_new_sale() # self.wizard_new_sale()
def wizard_new_sale(self): def wizard_new_sale(self):
# self.action_position() # self.action_position()
@ -1261,13 +1279,21 @@ class MainWindow(FrontWindow):
self.field_password_for_cancel_ask.setText('') self.field_password_for_cancel_ask.setText('')
self.set_state('cancel') self.set_state('cancel')
self.clear_right_panel() self.clear_right_panel()
self.create_new_sale() if self.sale_automatic:
self.create_new_sale()
def action_search_product(self): def action_search_product(self):
if self._state == 'cash': if self._state == 'cash':
return return
self.dialog_search_products.show() 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): def action_search_sale(self):
delta = str(datetime.now() - timedelta(2)) delta = str(datetime.now() - timedelta(2))
if self.type_pos_user == 'cashier': if self.type_pos_user == 'cashier':

View File

@ -1 +1 @@
<svg height="496pt" viewBox="-11 0 496 496.00008" width="496pt" xmlns="http://www.w3.org/2000/svg"><path d="m0 452.042969c0 24.265625 21.007812 43.957031 46.421875 43.957031h272.507813c22.773437 0 41.734374-15.832031 45.425781-36.589844 21.882812-3.410156 38.644531-21.554687 38.644531-43.398437v-198.011719h22.148438c1.542968.03125 3.058593-.390625 4.363281-1.207031l40.515625-26.316407c2.269531-1.46875 3.636718-3.988281 3.636718-6.691406 0-2.699218-1.367187-5.21875-3.636718-6.6875l-40.515625-26.582031c-1.277344-.910156-2.792969-1.4375-4.363281-1.515625h-22.148438v-43.640625c-.199219-2.683594-1.484375-5.167969-3.554688-6.886719l-92.226562-93.957031c-.515625-.738281-1.148438-1.386719-1.878906-1.914063l-.25-.234374c-1.507813-1.523438-3.566406-2.3789068-5.707032-2.367188h-214.984374c-22.773438 0-41.898438 15.835938-45.589844 36.589844-21.882813 3.410156-38.808594 21.554687-38.808594 43.398437zm136-250.042969v-37h281v37zm297-6.574219v-23.226562l17.847656 11.613281zm-124-166.609375 66.339844 68.183594h-55.648438c-2.777344.0625-5.46875-.980469-7.472656-2.902344-2.007812-1.921875-3.164062-4.566406-3.21875-7.34375zm-224.601562-12.816406h208.601562v70.753906c.121094 14.621094 12.070312 26.371094 26.691406 26.246094h67.308594v36h-258.601562c-4.582032.179688-8.246094 3.867188-8.398438 8.449219v1.023437l-23.808594-.472656h-.070312c-4.464844.117188-8.015625 3.78125-8 8.246094l.25 34.820312c.035156 4.394532 3.609375 7.9375 8 7.933594h23.628906v1.175781c0 4.417969 3.984375 7.824219 8.398438 7.824219h16.902343l-.109375 12c-.070312 4.574219 1.644532 8.996094 4.777344 12.328125 2.695312 2.875 6.425781 4.554687 10.363281 4.671875h97.136719c4.417969 0 8-3.582031 8-8s-3.582031-8-8-8h-96.246094c-.015625-1-.027344-.5-.027344-.621094l.113282-12.378906h225.691406v198.011719c0 15.441406-13.5 27.988281-30.089844 27.988281h-272.511718c-16.589844 0-30.398438-12.546875-30.398438-27.988281v-370.785157c0-.40625.261719-.820312.261719-1.242187.023437-.34375.023437-.6875 0-1.035156.585937-14.964844 13.921875-26.949219 30.136719-26.949219zm35.601562 177h-15.683594l-.339844-18.714844 16.023438.1875zm-104-113.011719c0-12.828125 10-23.660156 22-26.964843v362.988281c0 24.261719 20.988281 43.988281 46.398438 43.988281h263.367187c-3.699219 12-15.21875 20-28.835937 20h-272.507813c-16.589844 0-30.421875-12.515625-30.421875-27.957031zm0 0"/><path d="m96.460938 284h131.53125c4.417968 0 8-3.582031 8-8s-3.582032-8-8-8h-131.53125c-4.421876 0-8 3.582031-8 8s3.578124 8 8 8zm0 0"/><path d="m96.460938 323h228.910156c4.421875 0 8-3.582031 8-8s-3.578125-8-8-8h-228.910156c-4.421876 0-8 3.582031-8 8s3.578124 8 8 8zm0 0"/><path d="m96.460938 362h228.910156c4.421875 0 8-3.582031 8-8s-3.578125-8-8-8h-228.910156c-4.421876 0-8 3.582031-8 8s3.578124 8 8 8zm0 0"/><path d="m96.460938 401h228.910156c4.421875 0 8-3.582031 8-8s-3.578125-8-8-8h-228.910156c-4.421876 0-8 3.582031-8 8s3.578124 8 8 8zm0 0"/></svg> <svg height="464pt" viewBox="0 -68 464 464" width="464pt" xmlns="http://www.w3.org/2000/svg"><path d="m424 0 40 56h-464l48-56zm0 0" fill="#ff9811"/><path d="m0 56h464v32h-464zm0 0" fill="#ffa733"/><path d="m72 88h24v184h-24zm0 0" fill="#787680"/><path d="m368 88h24v184h-24zm0 0" fill="#787680"/><path d="m16 88h32v240h-32zm0 0" fill="#acabb1"/><path d="m416 88h32v240h-32zm0 0" fill="#acabb1"/><path d="m72 88h24v8h-24zm0 0" fill="#57565c"/><path d="m368 88h24v8h-24zm0 0" fill="#57565c"/><g fill="#787680"><path d="m16 88h32v16h-32zm0 0"/><path d="m416 88h32v16h-32zm0 0"/></g></svg>

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 585 B