minor fix

This commit is contained in:
Wilson Gomez 2023-10-23 15:08:59 -05:00
parent 554911ca39
commit d7b5d1ce58
6 changed files with 24 additions and 53 deletions

View File

@ -50,7 +50,7 @@ class Params(object):
"button_to_draft_active": False,
"server_printer": False,
"active_timeout": True,
"tasks_station": True,
"tasks_station": False,
"timeout": 10000,
"tablet_mode": False,
"theme": "base",

View File

@ -1705,11 +1705,11 @@ class DialogInfoProduct(QuickDialog):
]
domain.append([
'OR',
('barcode', 'ilike', '%' + filter + '%'),
('code', 'ilike', '%' + filter + '%'),
('name', 'ilike', '%' + filter + '%')
])
if self.parent._onebarcode_activated:
domain.append(('barcode', 'ilike', '%' + filter + '%'))
# if self._parent.cache_local:
# clause = [
# 'OR',

View File

@ -196,17 +196,16 @@ class FrontWindow(QMainWindow):
def load_modules(self):
self._sale_pos_restaurant = None
time1 = time.time()
self.Module = Model('ir.module', self.ctx, main_window=self)
module_names = [
'sale_pos_frontend_rest', 'sale_pos',
'sale_pos_frontend', 'account_credit_limit']
'sale_pos_frontend', 'account_credit_limit',
'product_onebarcode']
modules = self.Module.find([
('name', 'in', module_names),
('state', '=', 'activated'),
])
self.modules = {m['name']: m for m in modules}
print(time.time() - time1, 'final')
self.Config = Model('sale.configuration', self.ctx, main_window=self)
self.Sale = Model('sale.sale', self.ctx, main_window=self)
self._config, = self.Config.find([('id', '=', 1)])
@ -234,29 +233,7 @@ class FrontWindow(QMainWindow):
res = self.Sale.fields_get(['commission'])
self._commission_activated = True if res.get('commission') else False
self._credit_limit_activated = 'account_credit_limit' in self.modules
# _product = {
# 'name': 'product.product',
# 'fields': [
# 'template.name', 'code', 'write_date',
# 'description', 'template.sale_price_w_tax',
# 'template.account_category'
# ]
# }
# # self.cache_local = self._config.get('cache_products_local')
# if self._config['show_location_pos']:
# _product['fields'].append('location_')
# if self._config['show_stock_pos'] in ('value', 'icon'):
# if self._config['show_stock_pos'] == 'value':
# _product['fields'].append('quantity')
# if self._config['show_brand']:
# _product['fields'].append('template.brand.name')
# if self._config['encoded_sale_price']:
# _product['fields'].extend(
# ['image', 'image_icon', 'encoded_sale_price'])
self._onebarcode_activated = 'product_onebarcode' in self.modules
self.User = Model('res.user', self.ctx, main_window=self)
self._user, = self.User.find([('login', '=', self.user)])

View File

@ -51,6 +51,8 @@ _SALE_HISTORIC = [
'lines.note'
]
logger = logging.getLogger(__name__)
class AppWindow(FrontWindow):
@ -61,7 +63,6 @@ class AppWindow(FrontWindow):
super(AppWindow, self).__init__(context, params, title)
self.payment_ctx = {}
self.set_keys()
time1 = time.time()
StackMessages(self)
self.stock_context = None
self.sale_id = None
@ -80,10 +81,8 @@ class AppWindow(FrontWindow):
self.setup_sale_consumer()
self.setup_payment()
# self.set_domains()
print(time.time() - time1, 'set domains')
self.create_gui()
print(time.time() - time1, 'create gui')
self.message_bar.load_stack(self.stack_msg)
self.journal = {}
self.active_usb_printers = []
@ -100,7 +99,6 @@ class AppWindow(FrontWindow):
# self._input_text = ''
# self._sign = None
self.create_dialogs()
print(time.time() - time1, 'create dialogs')
self.store = StoreView(self, SALE_FIELDS)
if self.active_weighing:
from .electronic_scale import ScaleReader
@ -120,8 +118,6 @@ class AppWindow(FrontWindow):
matching_journal = next((j for j in self._journals if j['id'] == self.default_journal['id']), None)
if matching_journal:
self.default_journal = matching_journal
time6 = time.time()
print(time6 - time1, 'load final')
def get_defaults_variables(self):
self._clear_invoice_number = False
@ -138,17 +134,18 @@ class AppWindow(FrontWindow):
orders = []
tasks = []
version = compare_versions(self.modules['sale_pos_frontend_rest']['version'], '6.0.7')
print('pasa por esta new query')
if version in ('equal', 'higher'):
print('pasa por esta new query')
if not self.tasks_station:
orders = self.SaleLine.get_data_command(args)
else:
if self.tasks_station:
result = self.SaleLine.get_data_command_and_task(args)
orders = result['orders']
tasks = result['tasks']
else:
orders = self.SaleLine.get_data_command(args)
# TODO: for remove this option
else:
logger.warning('The backend sale_pos_frontend_rest is deprecation, update version')
records = self.Sale.get_orders_to_command(args)
for record in records:
orders += record['orders'].values()
@ -739,13 +736,10 @@ class AppWindow(FrontWindow):
if self.environment == 'restaurant':
self.panel_right_box = QWidget()
time3 = time.time()
# values = self.get_product_by_categories_dash()
values = self.product_categories
print(time.time() - time3, 'load products categories dash')
self.menu_dash = MenuDash(self, values, 'on_selected_item')
print('final dash')
self.order_front.hide()
vbox_order_front.addLayout(self.buttons_function, 0)
vbox_order_front.addLayout(self.grid_info, 0)
@ -1907,6 +1901,7 @@ class AppWindow(FrontWindow):
if not reversion and ln['order_sended'] in (True, ''):
continue
pd_id = ln['product.']['id']
print(pd_id, 'njnj')
try:
printers, cat_id = self.products_printers.get(str(pd_id))
cat_id = str(cat_id[0])
@ -1976,15 +1971,15 @@ class AppWindow(FrontWindow):
data_station = self.Sale.method_instance('get_data_for_stations', self.sale_id)
receipt = Receipt(context={}, environment='restaurant')
receipt.print_tasks(data_station.values())
result = self.receipt_order.print_orders(orders.values(), reversion)
lines_sended = result + lines_ids
print(lines_sended, 'this is lines printed')
if not reversion and lines_sended:
for line in lines:
if line['id'] in lines_sended:
line['order_sended'] = ''
self.model_sale_lines.update_record(line)
self.Sale.mark_commanded({'sale_id': self.sale_id, 'lines_ids': lines_sended})
self.Sale.mark_commanded({'lines_ids': lines_sended})
return result
def action_source(self):
@ -2159,8 +2154,8 @@ class AppWindow(FrontWindow):
dom.append(('state', '=', 'quotation'))
# dom.append(['payment_method', '!=', 'all_paid'])
time1 = time.time()
fields = self.dialog_search_sales.fields_names
print(fields, 'this is fields')
sales = self.Sale.find(dom, fields=fields, order=[('id', 'DESC')])
self.dialog_search_sales.set_from_values(sales)
if self.environment == 'retail':
@ -2171,7 +2166,6 @@ class AppWindow(FrontWindow):
]
sales_draft = self.Sale.search_count(dom_draft)
self.dialog_search_sales.set_counter_control(sales_draft)
print(time.time() - time1, 'search sales')
def on_search_sale_by_number(self):
target = self.dialog_search_sales.filter_field.text()
@ -2583,8 +2577,9 @@ class AppWindow(FrontWindow):
('template.name', 'ilike', '%{:}%'.format(tw)),
('description', 'ilike', '%{:}%'.format(tw)),
('code', 'ilike', '%{:}%'.format(tw)),
('barcode', '=', '%{:}%'.format(tw)),
]
if self._onebarcode_activated:
clause.append(('barcode', '=', '%{:}%'.format(tw)))
if self.environment == 'retail':
clause.append(('template.reference', 'ilike', '%{:}%'.format(tw)))
domain.append(clause)

View File

@ -846,10 +846,10 @@ class Receipt(object):
logging.info("Info: Printer is OK!")
try:
res = self._print_order(order, reversion)
result = self._print_order(order, reversion)
# if True:
if res:
res.extend(res)
if result:
res.extend(result)
elif order.get('lines_ids') and True:
res.extend(order['lines_ids'])
except Exception:

5
pospro
View File

@ -40,15 +40,14 @@ class SingleInstanceApp(QApplication):
cmdline = process.info['cmdline']
if name == PROCESS_NAME and OS_NAME == 'posix':
app_open = True
elif OS_NAME == 'nt' and isinstance(cmdline, list) and 'pospro' in cmdline):
elif OS_NAME == 'nt' and isinstance(cmdline, list) and 'pospro' in cmdline:
num_opens += 1
if app_open or num_opens > 1:
logger.error('La aplicación ya esta en ejecución')
logger.warning('La aplicación ya esta en ejecución')
self.show_already_running_dialog()
sys.exit(1)
def show_already_running_dialog(self):
msg = QMessageBox()
msg.setIcon(QMessageBox.Warning)