From d6af083f26a9f6415ba95e4e9b0d839d1d4d438a Mon Sep 17 00:00:00 2001 From: wilson gomez Date: Mon, 3 May 2021 14:33:21 -0500 Subject: [PATCH 1/2] minor fix search product info --- app/dialogs.py | 77 +++++++++++++++++++++++++++++++++++++++++++--- app/frontwindow.py | 3 +- app/main.py | 17 ++++++++-- 3 files changed, 89 insertions(+), 8 deletions(-) diff --git a/app/dialogs.py b/app/dialogs.py index 5041634..8c660cb 100644 --- a/app/dialogs.py +++ b/app/dialogs.py @@ -29,7 +29,7 @@ __all__ = [ 'DialogManageTables', 'DialogHistoricSales', 'DialogSaleForm', 'DialogCancelInvoice', 'DialogForceAssign', 'CombineProduct', 'DialogReports', 'DialogFixedDiscounts', 'DialogExpenses', - 'DialogInfoProduct', + 'DialogInfoProduct', 'SearchProductInfo' ] WIZARDS = { @@ -284,6 +284,58 @@ class SearchProduct(SearchWindow): cols_width=_cols_width, fill=True) +class SearchProductInfo(SearchWindow): + def __init__(self, parent): + _cols_width = [10, 80] + headers = OrderedDict() + headers['id'] = {'desc': ('ID'), 'type': 'char'} + headers['code'] = {'desc': ('COD'), 'type': 'char'} + if parent._config.get('show_stock_pos') in ['icon', 'value']: + headers['quantity'] = {'desc': ('STOCK'), 'type': 'char'} + _cols_width.append(60) + + if not parent.cache_local: + headers['name'] = {'desc': 'NOMBRE', 'type': 'char'} + else: + headers['template.name'] = {'desc': 'NOMBRE', 'type': 'char'} + + _cols_width.append(350) + + if parent._config.get('show_description_pos'): + headers['description'] = {'desc': 'DESCRIPCION', 'type': 'char'} + _cols_width.append(300) + + if parent._config.get('show_brand'): + headers['template.brand'] = {'desc': 'BRAND', 'type': 'char'} + _cols_width.append(100) + + price = {'desc': ('PRICE'), 'type': 'number'} + if not parent._config.get('encoded_sale_price'): + headers['template.sale_price_w_tax'] = price + else: + price['type'] = 'char' + headers['encoded_sale_price'] = price + + _cols_width.append(100) + + if parent._config.get('show_location_pos'): + headers['location.name'] = {'desc': 'BODEGA', 'type': 'char'} + _cols_width.append(100) + + methods = { + 'on_selected_method': 'on_selected_product_info', + 'on_return_method': 'on_search_product', + } + fields_names = list(headers.keys()) + try: + fields_names.remove('image') + except: + pass + self.fields_names = fields_names + super(SearchProductInfo, self).__init__(parent, headers, None, methods, + cols_width=_cols_width, fill=True) + + class DialogManageTables(QuickDialog): def __init__(self, parent): self.parent = parent @@ -1377,6 +1429,20 @@ class Help(HelpDialog): self.set_shortcuts(shortcuts) +class DialogListProduct(QuickDialog): + def __init__(self, parent): + self._parent = parent + vbox = QVBoxLayout() + grid = QGridLayout() + label_code = QLabel('CODIGO:') + label_code.setObjectName('label_info_product_code') + grid.addWidget(label_code, 1, 1) + self.input_code = QLineEdit() + self.input_code.setObjectName('input_info_product_code') + self.input_code.returnPressed.connect(lambda: self.search()) + grid.addWidget(self.input_code, 1, 2) + + class DialogInfoProduct(QuickDialog): def __init__(self, parent): self._parent = parent @@ -1394,8 +1460,9 @@ class DialogInfoProduct(QuickDialog): label_name.setObjectName('label_info_product_name') grid.addWidget(label_name, 2, 1) self.input_name = QLineEdit() - self.input_name.setReadOnly(True) + # self.input_name.setReadOnly(True) self.input_name.setObjectName('input_info_product_name') + self.input_name.returnPressed.connect(lambda: self.search()) grid.addWidget(self.input_name, 2, 2) label_price = QLabel('PRECIO:') @@ -1423,16 +1490,18 @@ class DialogInfoProduct(QuickDialog): self.input_code.setFocus() def fill(self, values): + self.input_code.setText(values['code']) self.input_name.setText(values['name']) sale_price = "{:,}".format(round(values['template']['sale_price_w_tax']+values['extra_tax'], 0)) self.input_price.setText(sale_price) self.input_quantity.setText(str(values['quantity'])) - def search(self): + def search(self, values=None): self.ok_button.setDefault(False) code = self.input_code.text() + if values: + code = values['code'] res = self.parent._search_product(code) - print(res) if res: self.fill(res) diff --git a/app/frontwindow.py b/app/frontwindow.py index fc0e82e..6500eed 100644 --- a/app/frontwindow.py +++ b/app/frontwindow.py @@ -20,7 +20,7 @@ from .dialogs import ( DialogHistoricSales, DialogSaleForm, DialogSource, DialogReports, DialogDeliveryParty, TipAmount, DeliveryAmount, DialogSalesmanCode, DialogFixedDiscounts, DialogComboProduct, DialogSplitSale, DialogExpenses, - DialogInfoProduct + DialogInfoProduct, SearchProductInfo ) from .constants import DIALOG_REPLY_YES @@ -190,6 +190,7 @@ class FrontWindow(QMainWindow): self.dialog_split_sale = DialogSplitSale(self) self.dialog_expenses = DialogExpenses(self) self.dialog_info_product = DialogInfoProduct(self) + self.dialog_search_product_info = SearchProductInfo(self) if self._commission_activated: self.dialog_agent = DialogAgent(self) if self.enviroment == 'restaurant' and self._sale_pos_restaurant: diff --git a/app/main.py b/app/main.py index e84fb51..ecd955d 100644 --- a/app/main.py +++ b/app/main.py @@ -1275,7 +1275,7 @@ class AppWindow(FrontWindow): self.dialog_consumer.show() def action_info_product(self): - self.dialog_info_product.show() + self.dialog_search_product_info.show() def action_print_sale(self): number = self.field_invoice_number.text() @@ -1864,6 +1864,13 @@ class AppWindow(FrontWindow): self._current_line_id = None self.add_product(record=self.dialog_search_products.current_row) + def on_selected_product_info(self): + if self.dialog_search_product_info.current_row: + self._current_line_id = None + record = self.dialog_search_product_info.current_row + self.dialog_info_product.search(record) + self.dialog_info_product.show() + def on_selected_icon_product(self): if self.dialog_search_products.current_row: code = self.dialog_search_products.current_row['code'] @@ -1976,6 +1983,9 @@ class AppWindow(FrontWindow): def on_search_product(self): target = self.dialog_search_products.filter_field.text() + target2 = self.dialog_search_product_info.filter_field.text() + if target2: + target = target2 if not target: return target_words = target.split(' ') @@ -2011,6 +2021,7 @@ class AppWindow(FrontWindow): limit=100, ctx=self.stock_context) self.dialog_search_products.set_from_values(products) + self.dialog_search_product_info.set_from_values(products) def on_search_party(self): target = self.dialog_search_parties.filter_field.text() @@ -2189,6 +2200,7 @@ class AppWindow(FrontWindow): ('barcode', '=', code), ('code', '=', code) ]) + if self.cache_local: clause = [ 'OR', @@ -2208,8 +2220,7 @@ class AppWindow(FrontWindow): if not products or len(products) > 1: self.message_bar.set('product_not_found') return False - else: - product = products[0] + product = products[0] return product def _check_quantity(self): From ea93805f9fd991ba6328613e8837e0493dc69220 Mon Sep 17 00:00:00 2001 From: wilson gomez Date: Mon, 3 May 2021 16:49:43 -0500 Subject: [PATCH 2/2] minor fix --- app/commons/search_window.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/commons/search_window.py b/app/commons/search_window.py index 5befdeb..deae7fc 100644 --- a/app/commons/search_window.py +++ b/app/commons/search_window.py @@ -211,6 +211,7 @@ class SearchWindow(QDialog): super(SearchWindow, self).show() def hide(self): + self.clear_filter() self.parent.setFocus() super(SearchWindow, self).hide()