fix show brand

refactory get order to cammand as server printer
This commit is contained in:
Wilson Gomez 2023-09-26 21:22:42 -05:00
parent 2d46e2573b
commit d8d48a9407
5 changed files with 48 additions and 28 deletions

View File

@ -360,11 +360,17 @@ class TableModel(QAbstractTableModel):
for name, data in self.headers.items():
if '.' in name:
attrs = name.split('.')
val = values.get(attrs[0] + '.')
if val:
val = val.get(attrs[1])
else:
val = values.get(name)
val = values
for attr in attrs:
try:
val = val[attr + '.']
except Exception:
val = val[attr]
# val = values.get(attrs[0] + '.')
# if val:
# val = val.get(attrs[1])
# else:
# val = values.get(name)
else:
val = values[name]
if val:

View File

@ -317,7 +317,7 @@ class SearchProduct(SearchWindow):
_cols_width_append(300)
if parent._config.get('show_brand'):
headers['template.brand'] = {'desc': 'MARCA', 'type': 'char'}
headers['template.brand.name'] = {'desc': 'MARCA', 'type': 'char'}
_cols_width_append(100)
if parent.enviroment == 'retail':

View File

@ -235,7 +235,7 @@ class FrontWindow(QMainWindow):
if self._config['show_stock_pos'] == 'value':
_product['fields'].append('quantity')
if self._config['show_brand']:
_product['fields'].append('brand.name')
_product['fields'].append('template.brand.name')
if self._config['encoded_sale_price']:
_product['fields'].extend(

View File

@ -136,31 +136,45 @@ class AppWindow(FrontWindow):
print(time6 - time1, 'load final')
def verify_print_order_automatic(self):
_date = str(datetime.now() - timedelta(hours=12))
dom = [
("shop", "=", self.shop['id']),
("state", "in", ("draft", "quotation")),
("lines.status_order", "=", 'requested'),
("lines", "!=", None),
("create_date", ">=", _date),
]
sales = self.Sale.find(dom, fields=['id'])
for sale in sales:
records = self.Sale.get_orders_to_command({'shop': self.shop['id']})
for record in records:
orders = record['orders']
tasks = record['tasks']
try:
args = {
'sale_id': sale['id'],
'repeat': False,
}
data_station = self.Sale.method_instance('get_data_for_stations', sale['id'])
receipt = Receipt(context={}, environment='restaurant')
receipt.print_tasks(data_station)
orders, sale_number = self.Sale.get_order2print(args)
result = self.receipt_order.print_orders(orders, kind='command')
if result:
self.Sale.mark_commanded({'sale_id': sale['id'], 'lines_ids': result})
self.Sale.mark_commanded({'sale_id': record['id'], 'lines_ids': result})
receipt = Receipt(context={}, environment='restaurant')
receipt.print_tasks(tasks)
except Exception as e:
print(e)
traceback.print_exc()
# _date = str(datetime.now() - timedelta(hours=12))
# dom = [
# ("shop", "=", self.shop['id']),
# ("state", "in", ("draft", "quotation")),
# ("lines.status_order", "=", 'requested'),
# ("lines", "!=", None),
# ("create_date", ">=", _date),
# ]
# sales = self.Sale.find(dom, fields=['id'])
# for sale in sales:
# try:
# args = {
# 'sale_id': sale['id'],
# 'repeat': False,
# }
# data_station = self.Sale.method_instance('get_data_for_stations', sale['id'])
# receipt = Receipt(context={}, environment='restaurant')
# receipt.print_tasks(data_station)
# orders, sale_number = self.Sale.get_order2print(args)
# result = self.receipt_order.print_orders(orders, kind='command')
# if result:
# self.Sale.mark_commanded({'sale_id': sale['id'], 'lines_ids': result})
# except Exception as e:
# print(e)
# traceback.print_exc()
self.timer = QTimer()
self.timer.timeout.connect(self.verify_print_order_automatic)
self.timer.start(30000)
@ -1766,7 +1780,7 @@ class AppWindow(FrontWindow):
self.receipt_order.print_orders(orders, reversion=True)
except Exception as e:
print(self.print_order, 'validar variable en opcion print_order=True en config_pos.ini')
logging.error('Printing order reversion fail!', e)
logging.error('Printing order reversion fail!')
def _print_order(self, sale_id, kind, reversion=False):
result = False

View File

@ -1 +1 @@
__version__ = "6.0.21"
__version__ = "6.0.22"