Add discount fixed

This commit is contained in:
Oscar Alvarez 2021-01-24 12:21:59 -05:00
parent af28b5deb8
commit ca52dfc105
4 changed files with 68 additions and 25 deletions

View file

@ -1,9 +1,9 @@
from .commons.dialogs import HelpDialog, QuickDialog
from PyQt5.QtCore import QRect, Qt
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (
QCheckBox, QTextEdit, QVBoxLayout, QGridLayout, QLineEdit, QPlainTextEdit,
QScrollArea, QHBoxLayout, QDoubleSpinBox, QDateEdit, QDesktopWidget,
QScrollArea, QHBoxLayout, QDoubleSpinBox, QDesktopWidget,
QLabel
)
@ -25,11 +25,11 @@ __all__ = [
'Comment', 'Position', 'DialogPayment', 'DialogTaxes', 'DialogChannel',
'DialogTableMoneyCount', 'DialogTableDeliveryParty', 'DialogDeliveryParty',
'Help', 'DeliveryPartySelected', 'DialogPrintInvoice', 'DialogStock',
'DialogGlobalDiscountTable', 'DialogSalesmanCode', 'DialogAgent',
'DialogAuthDiscounts', 'DialogSalesmanCode', 'DialogAgent',
'DialogOrder', 'DialogGlobalDiscount', 'DialogVoucher', 'DialogConsumer',
'DialogManageTables', 'DialogTableSaleConsumer', 'SaleConsumerSelected',
'DialogCancelInvoice', 'DialogForceAssign', 'AdditionProduct',
'DialogReports',
'DialogReports', 'DialogFixedDiscounts',
]
TYPE_VEHICLE = [
@ -375,7 +375,6 @@ class DialogConsumer(QuickDialog):
class DialogTableSaleConsumer(QuickDialog):
def __init__(self, parent):
width, height = get_screen()
col_sizes_tlines = [
field['width'] for field in parent.fields_sale_consumer
]
@ -384,7 +383,8 @@ class DialogTableSaleConsumer(QuickDialog):
method_selected_row=parent.sale_consumer_selected
)
table.setFixedSize(width / 1.5, height / 2)
width, height = get_screen()
table.setFixedSize(width * 0.5, height * 0.5)
vbox_ = QVBoxLayout()
layout = QVBoxLayout()
@ -478,7 +478,7 @@ class SaleConsumerSelected(QuickDialog):
super(SaleConsumerSelected, self).__init__(parent, 'action',
widgets=[vbox_])
width, height = get_screen()
self.setFixedSize(width / 1.2, height / 1.2)
self.setFixedSize(width * 0.4, height * 0.5)
def get_button(self):
self._parent.button_duplicate_sale = CustomButton(
@ -609,14 +609,32 @@ class DialogVoucher(QuickDialog):
# return dialog
class DialogGlobalDiscountTable(QuickDialog):
class DialogAuthDiscounts(QuickDialog):
def __init__(self, parent):
vbox_discounts = create_vbox(parent, parent.discounts,
print('====',parent.discounts)
vbox_discounts = create_vbox(
parent,
parent.discounts,
parent.on_selected_discount
)
super(DialogGlobalDiscountTable, self).__init__(parent, 'action',
size=(800, 500), widgets=[vbox_discounts])
self.setWindowTitle('DESCUENTO')
width, height = get_screen()
super(DialogAuthDiscounts, self).__init__(parent, 'action',
size=(width * 0.5, height * 0.6), widgets=[vbox_discounts])
self.setWindowTitle('DESCUENTOS AUTORIZADOS')
class DialogFixedDiscounts(QuickDialog):
def __init__(self, parent):
widgets = create_vbox(
parent,
parent.discounts_fixed,
parent.on_selected_discount
)
width, height = get_screen()
super(DialogFixedDiscounts, self).__init__(parent, 'action',
widgets=[widgets])
self.setFixedSize(width * 0.8, height * 0.7)
self.setWindowTitle('DESCUENTO/BONO')
class DialogDeliveryParty(QuickDialog):
@ -627,11 +645,11 @@ class DialogDeliveryParty(QuickDialog):
parent.on_selected_delivery_party,
dimension=[1.7, 1.8]
)
super(DialogDeliveryParty, self).__init__(parent, 'action',
size=(800, 500), widgets=[vbox_salesman])
self.setWindowTitle('ESCOJE EL DOMICILIARIO')
width, height = get_screen()
self.setFixedSize(width / 1.5, height / 1.5)
super(DialogDeliveryParty, self).__init__(parent, 'action',
size=(width * 0.5, height * 0.5), widgets=[vbox_salesman])
self.setWindowTitle('ESCOJE EL DOMICILIARIO')
self.setFixedSize(width * 0.5, height * 0.7)
class DeliveryPartySelected(QuickDialog):
@ -871,7 +889,7 @@ class EditLine(QuickDialog):
vbox_product = QVBoxLayout()
grid = QGridLayout()
qty = 2
width, height = get_screen()
parent.label_product = QLabel()
parent.label_product.setAlignment(alignCenter)
parent.label_product.setObjectName('label_product')
@ -945,15 +963,26 @@ class EditLine(QuickDialog):
method='action_addition_line',
name_style='mini_button',
)
button_discounts = CustomButton(
parent,
id='button_discount',
size='small',
icon=get_icon('discount'),
title=('DESCUENTO/BONO'),
method='action_discount_line',
name_style='mini_button',
)
hbox = QHBoxLayout()
vbox_product.addLayout(grid, 1)
vbox_product.addLayout(hbox, 0)
hbox.addWidget(button_delete, 0)
hbox.addWidget(button_discounts, 0)
if parent.enviroment == 'restaurant':
hbox.addWidget(button_addition, 0)
super(EditLine, self).__init__(parent, 'action',
widgets=[vbox_product], size=[600, 900])
widgets=[vbox_product])
self.setFixedSize(width * 0.5, height * 0.7)
self.accepted.connect(parent.dialog_product_edit_accepted)

View file

@ -16,9 +16,10 @@ from .dialogs import (
DialogGlobalDiscount, DialogPaymentTerm, DialogStock, DialogOrder,
DialogForceAssign, DialogTaxes, DialogCancelInvoice, EditLine, DialogAgent,
DialogConsumer, DialogManageTables, DialogTableMoneyCount, AdditionProduct,
DialogGlobalDiscountTable, DeliveryPartySelected, DialogTableDeliveryParty,
DialogAuthDiscounts, DeliveryPartySelected, DialogTableDeliveryParty,
DialogTableSaleConsumer, SaleConsumerSelected, DialogChannel, DialogReports,
DialogDeliveryParty, TipAmount, DeliveryAmount, DialogSalesmanCode
DialogDeliveryParty, TipAmount, DeliveryAmount, DialogSalesmanCode,
DialogFixedDiscounts,
)
from .constants import DIALOG_REPLY_YES
@ -168,7 +169,8 @@ class FrontWindow(QMainWindow):
self.dialog_voucher = DialogVoucher(self)
self.dialog_print_invoice = DialogPrintInvoice(self)
self.dialog_global_discount = DialogGlobalDiscount(self)
self.dialog_global_discount_table = DialogGlobalDiscountTable(self)
self.dialog_auth_discount = DialogAuthDiscounts(self)
self.dialog_fixed_discount = DialogFixedDiscounts(self)
self.dialog_payment_term = DialogPaymentTerm(self)
self.dialog_search_sales.activate_counter()
self.dialog_product_stock = DialogStock(self.dialog_search_products)
@ -278,6 +280,9 @@ class FrontWindow(QMainWindow):
self.Party = FastModel('party.party', self.ctx)
self.DeliveryParty = FastModel('sale.delivery_party', self.ctx)
self.Taxes = FastModel('account.tax', self.ctx)
self.Discount = FastModel('sale.discount', self.ctx, fields=[
'name', 'active', 'discount', 'type_discount'
])
self.ActionReport = FastModel('ir.action.report', self.ctx)
if self._commission_activated:
self.Agent = FastModel('commission.agent', self.ctx)
@ -302,7 +307,12 @@ class FrontWindow(QMainWindow):
if self.salesman_ids:
dom_salesman.append(('id', 'in', self.salesman_ids))
self.discounts = self.shop.get('discounts', [])
self.discounts = self.Discount.find([
('type_discount', '=', 'percentage')
])
self.discounts_fixed = self.Discount.find([
('type_discount', '=', 'fixed')
])
self.delivery_man_table = self.shop.get('delivery_man', [])
self.delivery_man = [d for d in self.delivery_man_table if d['active']]
self._payment_terms = self.PaymentTerm.find([('active', '=', True)])

View file

@ -297,7 +297,7 @@
</message>
</context>
<context>
<name>DialogGlobalDiscountTable</name>
<name>DialogAuthDiscounts</name>
<message>
<location filename="../dialogs.py" line="616"/>
<source>CHOOSE DISCOUNT</source>

View file

@ -1084,7 +1084,7 @@ class MainWindow(FrontWindow):
self.clear_money_count_table()
def action_table_discount(self):
self.dialog_global_discount_table.exec_()
self.dialog_auth_discount.exec_()
def action_tax(self):
self.dialog_tax.exec_()
@ -1681,8 +1681,9 @@ class MainWindow(FrontWindow):
self.add_product(record=record, list_price=list_price)
def on_selected_discount(self, discount):
self.dialog_global_discount_table.close()
self.dialog_auth_discount.close()
self.dialog_control_panel.close()
print('Discount/..........', discount)
if self._state == 'payment':
dialog = self.dialog('cant_add_discount')
dialog.exec_()
@ -2288,6 +2289,9 @@ class MainWindow(FrontWindow):
def on_change_line_selected(self, key):
self.table_sale_lines.moved_selection(key)
def action_discount_line(self):
self.dialog_fixed_discount.exec_()
def action_addition_line(self):
if not self._current_line:
return