add option select list price

This commit is contained in:
wilsongomez 2022-05-02 17:25:05 -05:00
parent fd4fc8d714
commit c9b9ae488a
11 changed files with 63 additions and 73 deletions

View File

@ -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"

View File

@ -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'))

View File

@ -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):

View File

@ -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

View File

@ -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)

View File

@ -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'
],
}
}

View File

@ -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,

View File

@ -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):

View File

@ -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}),

1
app/version.py Normal file
View File

@ -0,0 +1 @@
__version__ = "5.0.47"

View File

@ -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',