minor fix search product and set quantity

with barcode
This commit is contained in:
Wilson Gomez 2023-03-10 16:20:59 -05:00
parent 908ab45af2
commit 2229ea6622
1 changed files with 13 additions and 8 deletions

View File

@ -712,12 +712,14 @@ class AppWindow(FrontWindow):
def button_plus_pressed(self):
error = False
print('ingresa a este registro, ', self._input_text, self._amount_text)
if self._input_text == '' and self._amount_text == '0':
return
if self._state in ('paid', 'disabled'):
return
if self._sign in ('*', '-', '/'):
self._sale_line = self.table_sale_lines.get_selected_clicked()
print(self._sale_line, 'validate')
if self._sale_line and self._sale_line.get('type') \
and self._state == 'add' \
and self.model_sale_lines.rowCount() > 0:
@ -804,8 +806,12 @@ class AppWindow(FrontWindow):
quantity = Decimal(eval_value)
try:
product_id = self._sale_line['product.']['id']
except:
product_id = self._sale_line['product']['id']
except Exception as e:
print(e)
try:
product_id = self._sale_line['product']['id']
except:
product_id = self._sale_line['product']
if product_id and self.stock_context:
_product, = self.Product.find(
[('id', '=', product_id)],
@ -2478,8 +2484,6 @@ class AppWindow(FrontWindow):
domain = [clause]
products = self.local_db.find_product_elastic(domain, limit=100)
else:
print('domain : ', domain)
print('este es el context ', self.stock_context)
products = self.Product.find(
domain,
# context=self.stock_context,
@ -2490,12 +2494,12 @@ class AppWindow(FrontWindow):
'extra_tax', 'template.sale_price_w_tax',
'template.default_uom', 'write_date']
)
print('resultado ', products)
if not products or len(products) > 1:
self.message_bar.set('product_not_found')
return False
product = products[0]
# sadsd
return product
def _check_quantity(self):
@ -2544,7 +2548,7 @@ class AppWindow(FrontWindow):
if record:
product_id = record['id']
elif code:
# REMOVE ME
# REMOVE ME THIS OPTION IS FOR BARCODE
product = self._search_product(code)
if product:
product_id = product['id']
@ -2580,7 +2584,8 @@ class AppWindow(FrontWindow):
self._sale_line = res
self._current_line_id = res['id']
self.add_sale_line(res)
self._sale_line['product'] = record
if record:
self._sale_line['product'] = record
self.product_id = product_id
self.message_bar.set('system_ready')
self.set_amounts()
@ -3158,7 +3163,7 @@ class AppWindow(FrontWindow):
def keyPressEvent(self, event):
key = event.key()
print('key press event', key)
print('key press event', key, self._state)
self._keyStates[key] = True
if self._state == 'add' and key not in self.keys_input and \
key not in (Qt.Key_Enter, Qt.Key_End):