minor fix release table

This commit is contained in:
wilson gomez 2022-02-05 11:46:26 -05:00
parent e6c6753b96
commit df3ad643f3
4 changed files with 22 additions and 4 deletions

View File

@ -75,7 +75,7 @@ SALE_FIELDS = [
]
KIND = [
('', ''),
# ('', ''),
('take_away', 'PARA LLEVAR'),
('delivery', 'DOMICILO'),
('to_table', 'A LA MESA'),

View File

@ -1081,6 +1081,15 @@ class AppWindow(FrontWindow):
self.dialog_manage_tables.open_tables()
self.dialog_manage_tables.exec_()
def action_release_table(self, table_id):
dialog = self.dialog('release_table', response=True)
response = dialog.exec_()
if response == DIALOG_REPLY_NO:
return
to_drop = {'state': 'available', 'sale': None}
self.RestTables.write([table_id], to_drop)
return to_drop
def action_tip(self):
if self._state in ['finished']:
return
@ -3128,7 +3137,6 @@ class AppWindow(FrontWindow):
self._current_line_id = line['id']
to_write = {}
for k, v in data.items():
print(k, 'order de acciones')
if k in ['description', 'note']:
to_write[k] = v
elif k == 'unit_price' and float(v) != current_unit_price:

View File

@ -1,5 +1,6 @@
import os
from PyQt5.QtWidgets import QGridLayout, QPushButton
from PyQt5.QtCore import Qt
DIR_SHARE = os.path.abspath(
os.path.normpath(os.path.join(__file__, '..', '..', 'share')))
@ -25,8 +26,9 @@ button_style_1 = """
class MixButton(QPushButton):
def __init__(self, value, activate):
def __init__(self, value, activate, parent):
super(MixButton, self).__init__()
self.parent = parent
self.name = value['name']
self.table_id = value['id']
self.set_data(value)
@ -38,6 +40,13 @@ class MixButton(QPushButton):
def activate_method(self):
self.activate(self.table_id)
def mousePressEvent(self, event):
if event.button() == Qt.RightButton and self.state != 'available':
res = self.parent.action_release_table(self.table_id)
if res:
self.set_data(res)
super(MixButton, self).mousePressEvent(event)
def set_data(self, record):
self.state = record['state']
self.sale_id = record['sale']
@ -65,7 +74,7 @@ class ManageTables(QGridLayout):
self.buttons = {}
positions = [(i, j) for i in range(rows) for j in range(columns)]
for position, value in zip(positions, tables):
button = MixButton(value, self.activate_method)
button = MixButton(value, self.activate_method, self.parent)
self.buttons[button.table_id] = button
self.addWidget(button, *position)

View File

@ -56,4 +56,5 @@ class StackMessages(QWidget):
'missing_delivery_party': ('error', 'FALTA ASIGNAR EL DOMICILIARIO!'),
'select_products_to_split': ('question', 'SELECCIONE LOS PRODUCTOS A DIVIDIR!'),
'fail_send_invoice': ('info', 'FALLO LA VALIDACION DE LA FACTURA ELECTRONICA!'),
'release_table': ('question', 'DESEA LIBERAR LA MESA?'),
}