validate qty mix required

This commit is contained in:
Wilson Gomez 2023-06-27 17:06:41 -05:00
parent 8e5a608192
commit 66633d2f67
3 changed files with 68 additions and 9 deletions

View File

@ -10,7 +10,7 @@ from .commons.dialogs import HelpDialog, QuickDialog
from PySide6.QtCore import Qt, QSize
from PySide6.QtWidgets import (
QCheckBox, QTextEdit, QVBoxLayout, QGridLayout, QLineEdit, QPlainTextEdit,
QScrollArea, QHBoxLayout, QDoubleSpinBox, QLabel, QMessageBox
QScrollArea, QHBoxLayout, QDoubleSpinBox, QLabel, QMessageBox, QWidget
)
from .proxy import Report
@ -1469,16 +1469,38 @@ class CombineProduct(QuickDialog):
class DialogComboProduct(QuickDialog):
def __init__(self, parent):
self.box = QVBoxLayout()
self.box.setObjectName('grid_buttons')
qwidget = QWidget()
self.hbox = QHBoxLayout(qwidget)
qwidget.setFixedHeight(50)
width, height = get_screen()
self.method_action = getattr(parent, 'on_selected_item_combo')
self.parent = parent
label = QLabel('SELECCIONE LOS PRODUCTOS')
label.setObjectName('label_combo_product')
self.box.addWidget(label)
self.hbox.addWidget(label)
self.label_qty_min = QLabel('QTY MIN.')
self.label_qty_min.setObjectName('label_qty_min')
self.hbox.addWidget(self.label_qty_min)
self.label_qty_min_req = QLabel("")
self.label_qty_min_req.setObjectName('label_qty_min_req')
self.hbox.addWidget(self.label_qty_min_req)
self.label_qty = QLabel('QTY.')
self.label_qty.setObjectName('label_qty')
self.hbox.addWidget(self.label_qty)
self.label_qty_add = QLabel("")
self.label_qty_add.setObjectName('label_qty_add')
self.hbox.addWidget(self.label_qty_add)
self.vbox = QVBoxLayout()
self.vbox.setObjectName('grid_buttons')
self.vbox.addWidget(qwidget)
super(DialogComboProduct, self).__init__(
parent, 'action', widgets=[self.box]
parent, 'action', widgets=[self.vbox]
)
self.setWindowTitle('PRODUCTO EN COMBO')
self.setFixedSize(int(width * 0.7), int(height * 0.6))
@ -1496,11 +1518,39 @@ class DialogComboProduct(QuickDialog):
style='standard_button'
)
if hasattr(self, 'scroll_area'):
_ = self.box.removeWidget(self.scroll_area)
_ = self.vbox.removeWidget(self.scroll_area)
self.scroll_area = QScrollArea()
self.scroll_area.setWidgetResizable(True)
self.scroll_area.setWidget(grid_buttons)
self.box.addWidget(self.scroll_area)
self.vbox.addWidget(self.scroll_area)
def close(self):
if self.validate_close_dialog():
self.label_qty_add.setText("")
self.label_qty_min_req.setText("")
super(QuickDialog, self).close()
def closeEvent(self, event):
if self.validate_close_dialog():
super(QuickDialog, self).closeEvent(event)
def dialog_rejected(self):
if self.validate_close_dialog():
super().dialog_rejected()
def dialog_accepted(self):
if self.validate_close_dialog():
super().dialog_accepted()
def validate_close_dialog(self):
qty_add = self.label_qty_add.text()
qty_req = self.label_qty_min_req.text()
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_()
return False
return True
class DialogSplitSale(QuickDialog):

View File

@ -2320,6 +2320,12 @@ class AppWindow(FrontWindow):
def on_selected_item_combo(self, record):
list_price = 0
qty_text = self.dialog_combo_product.label_qty_add.text()
try:
qty = int(qty_text) + 1
except:
qty = 1
self.dialog_combo_product.label_qty_add.setText(str(qty))
self.on_selected_item(record, list_price)
def on_selected_item_mix(self, record):
@ -3114,12 +3120,14 @@ class AppWindow(FrontWindow):
fields=["code", "description", "extra_tax", "name", "sale_uom",
"quantity", "sale_price_w_tax", "template.account_category",
"template.sale_price_w_tax", "template.rec_name",
'products_mix.code', 'products_mix.name'
'products_mix.code', 'products_mix.name', "quantity_mix_required"
])
products_mix = product[0].get('products_mix.')
if not products_mix:
return
min_mix_required = str(product[0].get('quantity_mix_required'))
self.dialog_combo_product.set_buttons(products_mix)
self.dialog_combo_product.label_qty_min_req.setText(min_mix_required)
self.dialog_combo_product.exec_()
self.dialog_combo_product.close()

View File

@ -66,5 +66,6 @@ class StackMessages(QWidget):
'dont_delete_product': ('error', 'PARA ELIMINAR UN PRODUCTO DE LA VENTA DEBE FORZAR A BORRADOR EN TRYTON.'),
'base_uvt_pos': ('info', 'VENTA SUPERA LA BASE, \n DEBE SELECCIONAR VENTA ELECTRONICA.'),
'process_invoice_failed': ('error', 'ERROR AL PROCESAR FACTURA'),
'confirm_agent': ('question', 'Confirmar comision de agente')
'confirm_agent': ('question', 'Confirmar comision de agente'),
'qty_combo_min_req': ('error', 'Cantidad minima requerida!'),
}