diff --git a/app/__init__.py b/app/__init__.py index ee476d1..8b13789 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,3 +1 @@ -# This file is part of Tryton. The COPYRIGHT file at the top level of -# this repository contains the full copyright notices and license terms. -__version__ = "5.0.46" + diff --git a/app/commons/forms.py b/app/commons/forms.py index 86c06b3..b0ddbfb 100644 --- a/app/commons/forms.py +++ b/app/commons/forms.py @@ -348,6 +348,10 @@ class ComboBox(QComboBox): selection_model.findItems(str(3), column=0) self.method_on_change = None self.currentIndexChanged.connect(self.on_change) + if data.get('default'): + self.set_from_id(data['default']['id']) + if self.form: + self.form.setState(self.key, self.get_id()) if data.get('on_change'): self.method_on_change = getattr(self.parent, data.get('on_change')) diff --git a/app/commons/menu_buttons.py b/app/commons/menu_buttons.py index 4741686..a872efa 100644 --- a/app/commons/menu_buttons.py +++ b/app/commons/menu_buttons.py @@ -114,7 +114,7 @@ class MenuDash(QWidget): new_view.show() self.main.addWidget(new_view) self.current_view = view_id - self.setGeometry(int(self.rect_expanded)) + self.setGeometry(self.rect_expanded) def create_categories(self): # set the list model @@ -231,7 +231,7 @@ class MenuDash(QWidget): self.expand = True self.parent.show_right_panel(False) self.close_menu.show() - self.setGeometry(int(self.rect_expanded)) + self.setGeometry(self.rect_expanded) class GridButtons(QWidget): diff --git a/app/frontwindow.py b/app/frontwindow.py index c32ba58..02adb38 100644 --- a/app/frontwindow.py +++ b/app/frontwindow.py @@ -5,7 +5,6 @@ import logging from pathlib import Path from PyQt5.QtWidgets import QMainWindow, QDesktopWidget, QLineEdit from PyQt5.QtCore import QTimer, QThread, pyqtSignal - from .commons.dialogs import QuickDialog from .commons.dblogin import safe_reconnect from .proxy import FastModel @@ -23,9 +22,10 @@ from .dialogs import ( DialogInfoProduct ) from .constants import DIALOG_REPLY_YES +from .version import __version__ + __all__ = ['FrontWindow', 'ClearUi'] - parent = Path(__file__).parent file_base_css = os.path.join(str(parent), 'css', 'base.css') @@ -44,6 +44,7 @@ class FrontWindow(QMainWindow): self.window().setWindowTitle(title) self.setObjectName('WinMain') self.conn = connection + self.version = __version__ self._context = connection.context self.set_params(params) self.logger = logging.getLogger('app_logger') @@ -356,6 +357,7 @@ class FrontWindow(QMainWindow): } # if self._source: self.Source = FastModel('sale.source', self.ctx) + self.Pricelist = FastModel('product.price_list', self.ctx) return True diff --git a/app/main.py b/app/main.py index ef2b77d..4fded39 100644 --- a/app/main.py +++ b/app/main.py @@ -44,7 +44,6 @@ _SALE_HISTORIC = [ 'total_amount_cache', 'lines' ] - class AppWindow(FrontWindow): def __init__(self, connection, params, mode_conn): @@ -165,6 +164,11 @@ class AppWindow(FrontWindow): return return sales[0] + def get_price_lists(self): + price_lists = self.Pricelist.find([]) + price_lists = [(l['id'], l['name']) for l in price_lists] + return price_lists + def check_empty_sale(self): sale = self.get_current_sale() if sale and self.model_sale_lines.rowCount() == 0 \ @@ -211,7 +215,7 @@ class AppWindow(FrontWindow): # Printing order context if self.print_order: - self.receipt_order = Receipt(ctx_printing) + self.receipt_order = Receipt(ctx_printing, environment=self.enviroment) self.set_default_printer() def set_default_printer(self, printer=None): @@ -382,7 +386,7 @@ class AppWindow(FrontWindow): # LEFT TABLE COMPONENTS button_functions = ButtonsFunction(self) - + info_fields = [ ('party', { 'name': 'CLIENTE', @@ -432,6 +436,17 @@ class AppWindow(FrontWindow): ] self.sources = self.Source.find([]) + if self.enviroment != 'restaurant': + info_fields.append( + ('list_price', { + 'name': 'LISTA DE PRECIOS', + 'placeholder': False, + 'type': 'selection', + 'values': self.get_price_lists(), + 'default': self.shop['price_list'], + 'size': self.screen_size, + 'color': self.label_color + })) info_fields.append( ('source', { @@ -772,7 +787,10 @@ class AppWindow(FrontWindow): } if self._config.get('use_price_list'): args['use_price_list'] = True - rec = self.SaleLine.faster_set_quantity(args) + ctx = None + if hasattr(self, 'field_list_price'): + ctx = {'price_list': self.field_list_price.get_id()} + rec = self.SaleLine.faster_set_quantity(args, ctx=ctx) except: return self.message_bar.set('quantity_not_valid') @@ -2475,7 +2493,11 @@ class AppWindow(FrontWindow): if list_price is not None: data['list_price'] = list_price - res = self.Sale.faster_add_product(data) + + ctx = None + if hasattr(self, 'field_list_price'): + ctx = {'price_list': self.field_list_price.get_id()} + res = self.Sale.faster_add_product(data, ctx=ctx) self._sale_line = res self._current_line_id = res['id'] self.add_sale_line(res) @@ -3119,55 +3141,6 @@ class AppWindow(FrontWindow): self.set_amounts() self.dialog_product_edit.clear() - # unit_price = data.get('unit_price') - # current_unit_price = float(str(round(line['unit_price_w_tax'], 0))) - # self._current_line_id = line['id'] - # if unit_price: - # diff = abs(current_unit_price - float(unit_price)) - # if float(unit_price) > current_unit_price: - # self.set_unit_price(unit_price, discount=False) - # elif diff > 1: - # self._sign = '/' - # self._process_price(unit_price, line) - # self._sign = None - # _record = self.SaleLine.write([data['id']], {}) - # - # quantity = data.get('quantity', None) - # previous_qty = Decimal(line['quantity']) - # if quantity and quantity != previous_qty: - # quantity = data.pop('quantity') - # qty_data = { - # 'id': data['id'], - # 'quantity': to_float(quantity, 2) - # } - # if self._config.get('use_price_list'): - # qty_data['use_price_list'] = True - # _record = self.SaleLine.faster_set_quantity(qty_data) - # - # to_update = {} - # if data.get('description'): - # to_update['description'] = data['description'] - # - # if data.get('note'): - # to_update['note'] = data['note'] - # - # if to_update: - # _record = self.SaleLine.write([data['id']], to_update) - # - # if not _record: - # return - # - # if not _record.get('unit.symbol'): - # _record['unit.symbol'] = _record['unit']['symbol'] - # if not _record.get('product.template.name'): - # _record['product.template.name'] = _record['product']['template']['name'] - # if not _record.get('product.code'): - # _record['product.code'] = _record['product']['code'] - # - # self.model_sale_lines.update_record(_record) - # self.set_amounts() - # self.dialog_product_edit.clear() - def edit_line_sale(self, data, line): current_unit_price = float(str(round(line['unit_price_w_tax'], 0))) sale_line, = self.SaleLine.find([ @@ -3195,7 +3168,10 @@ class AppWindow(FrontWindow): } if self._config.get('use_price_list'): qty_data['use_price_list'] = True - self.SaleLine.faster_set_quantity(qty_data) + ctx = None + if hasattr(self, 'field_list_price'): + ctx = {'price_list': self.field_list_price.get_id()} + self.SaleLine.faster_set_quantity(qty_data, ctx=ctx) elif k == 'update_base_price': self.set_unit_price(base_price, discount=False) diff --git a/app/models.py b/app/models.py index d01ce0e..6b55fac 100644 --- a/app/models.py +++ b/app/models.py @@ -101,13 +101,14 @@ MODELS = { 'shop.computer_authorization', 'shop.manual_authorization', 'shop.credit_note_electronic_authorization', 'shop.salesmans', 'shop.debit_note_electronic_authorization', 'shop.delivery_man', + 'shop.price_list' ] }, 'sale.shop': { 'rec_name': 'name', 'fields': ['taxes', 'product_categories', 'party', 'invoice_copies', 'warehouse', 'payment_term', 'salesmans', 'delivery_man', - 'discounts'] + 'discounts', 'price_list'] }, 'product.product': { 'rec_name': 'rec_name', @@ -181,4 +182,10 @@ MODELS = { 'name' ] }, + 'product.price_list':{ + 'rec_name': 'rec_name', + 'fields': [ + 'name' + ], + } } diff --git a/app/proxy.py b/app/proxy.py index 0d14e97..78f22cb 100644 --- a/app/proxy.py +++ b/app/proxy.py @@ -128,7 +128,9 @@ class FastModel(object): route = self.api + '/' + target return route - def __call__(self, values=None): + def __call__(self, values=None, ctx=None): + if ctx: + self.ctx.update(ctx) args_ = { 'model': self.model, 'method': self.method, diff --git a/app/reporting.py b/app/reporting.py index e38060d..c14ca50 100755 --- a/app/reporting.py +++ b/app/reporting.py @@ -824,7 +824,6 @@ class Receipt(object): self._printer.text('TURNO: %s' % str(turn)) self.print_enter() self.print_enter() - if self._environment != 'retail': kind = order.get('kind', 'delivery') if kind == 'take_away': @@ -934,12 +933,12 @@ class Receipt(object): self.print_enter() self.print_enter() self.print_enter() - if self._environment != 'retail': - self._printer.set(custom_size=True, width=2, height=2, align='center') - title = f'+ + + {_kind} + + +' - self._printer.text(title) - self.print_enter() - self.print_enter() + # if self._environment != 'retail': + # self._printer.set(custom_size=True, width=2, height=2, align='center') + # title = f'+ + + {_kind} + + +' + # self._printer.text(title) + # self.print_enter() + # self.print_enter() @classmethod def get_authorization(cls, auth): diff --git a/app/status_bar.py b/app/status_bar.py index d146631..0232795 100644 --- a/app/status_bar.py +++ b/app/status_bar.py @@ -11,6 +11,7 @@ class StatusBar(QWidget): super(StatusBar, self).__init__() p = parent values = OrderedDict([ + ('stb_version', {'name': 'VERSION', 'value': p.version}), ('stb_shop', {'name': 'SUCURSAL', 'value': p.shop['name']}), ('stb_device', {'name': 'TERMINAL', 'value': p.device['name']}), ('stb_database', {'name': 'DB', 'value': p.database}), diff --git a/app/version.py b/app/version.py new file mode 100644 index 0000000..6ce09f3 --- /dev/null +++ b/app/version.py @@ -0,0 +1 @@ +__version__ = "5.0.47" \ No newline at end of file diff --git a/setup.py b/setup.py index bbbe982..4958989 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup import os import glob import shutil - +from .app import __version__ def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() @@ -34,7 +34,7 @@ if os.name == 'posix': setup(name='presik_pos', - version='5.0.42', + version=__version__, description='POS Client for Tryton', author='Oscar Alvarez', author_email='gerente@presik.com',