Add store
This commit is contained in:
parent
021c340a32
commit
f5d8882e1c
|
@ -106,7 +106,7 @@ class ButtonsFunction(QGridLayout):
|
|||
['button_search_sale', self.tr('S. SALE'), 'action_search_sale'],
|
||||
['button_print_sale', self.tr('PRINT'), 'action_print_sale'],
|
||||
[salesman_button, salesman_desc, 'action_salesman'],
|
||||
['button_delivery_men', self.tr('DELIVERY MEN'), 'action_delivery_men']
|
||||
['button_delivery_party', self.tr('DELIVERY MEN'), 'action_delivery_party']
|
||||
# ['button_position', self.tr('POSITION'), 'action_position'],
|
||||
])
|
||||
|
||||
|
|
|
@ -209,7 +209,6 @@ class FieldInput(QLineEdit):
|
|||
validator = QDoubleValidator()
|
||||
validator.setDecimals(2)
|
||||
self.setValidator(validator)
|
||||
print('Value ...', value)
|
||||
self.method_on_change = getattr(obj, 'on_change_input')
|
||||
if not amount:
|
||||
self.zero()
|
||||
|
|
|
@ -20,7 +20,7 @@ from .tools import get_icon
|
|||
__all__ = [
|
||||
'ControlPanel', 'SearchSale', 'SearchParty', 'SearchProduct', 'SaleLine',
|
||||
'Comment', 'Position', 'DialogPayment', 'DialogTaxes', 'DialogChannel',
|
||||
'DialogTableMoneyCount', 'DialogTableDeliveryParty', 'DialogDeliveryMen',
|
||||
'DialogTableMoneyCount', 'DialogTableDeliveryParty', 'DialogDeliveryParty',
|
||||
'Help', 'DeliveryPartySelected', 'DialogPrintInvoice', 'DialogStock',
|
||||
'DialogGlobalDiscountTable', 'DialogSalesman', 'DialogAgent',
|
||||
'DialogOrder', 'DialogGlobalDiscount', 'DialogVoucher', 'DialogConsumer',
|
||||
|
@ -627,23 +627,23 @@ class DialogGlobalDiscountTable(QWidget):
|
|||
return dialog
|
||||
|
||||
|
||||
class DialogDeliveryMen(QWidget):
|
||||
class DialogDeliveryParty(QWidget):
|
||||
def __init__(self, parent):
|
||||
super(DialogDeliveryMen, self).__init__(parent)
|
||||
super(DialogDeliveryParty, self).__init__(parent)
|
||||
self._parent = parent
|
||||
|
||||
def get(self):
|
||||
string_ = self.tr('CHOOSE DELIVERY MEN')
|
||||
newlist = sorted(self._parent.delivery_man, key=itemgetter('rec_name'))
|
||||
string_ = self.tr('CHOOSE DELIVERY MAN')
|
||||
new_list = sorted(self._parent.delivery_parties, key=itemgetter('rec_name'))
|
||||
man_ = [[e['id'], '', e['rec_name'], e['number_plate'] or ' ']
|
||||
for e in newlist]
|
||||
for e in new_list]
|
||||
vbox_salesman = create_vbox(self._parent, man_,
|
||||
self._parent.on_selected_delivery_men, dimension=[1.7, 1.8])
|
||||
self._parent.on_selected_delivery_party, dimension=[1.7, 1.8])
|
||||
dialog = QuickDialog(self._parent, 'action', size=(800, 500),
|
||||
widgets=[vbox_salesman])
|
||||
dialog.setWindowTitle(string_)
|
||||
width, height = get_screen()
|
||||
dialog.setFixedSize(width/1.5, height/1.5)
|
||||
dialog.setFixedSize(width / 1.5, height / 1.5)
|
||||
return dialog
|
||||
|
||||
|
||||
|
@ -657,15 +657,15 @@ class DeliveryPartySelected(QWidget):
|
|||
vbox_ = QVBoxLayout()
|
||||
grid = QGridLayout()
|
||||
|
||||
label_delivery_men = QLabel(self.tr('DELIVERY MEN:'))
|
||||
label_delivery_men.setAlignment(alignCenter)
|
||||
label_delivery_men.setObjectName('label_delivery_men')
|
||||
grid.addWidget(label_delivery_men, 1, 1)
|
||||
self._parent.row_delivery_men = QLineEdit()
|
||||
self._parent.row_delivery_men.setObjectName('row_delivery_men')
|
||||
self._parent.row_delivery_men.textChanged.connect(
|
||||
lambda: self._parent.update_delivery_party('delivery_men'))
|
||||
grid.addWidget(self._parent.row_delivery_men, 1, 2)
|
||||
label_delivery_party = QLabel(self.tr('DELIVERY PARTY:'))
|
||||
label_delivery_party.setAlignment(alignCenter)
|
||||
label_delivery_party.setObjectName('label_delivery_party')
|
||||
grid.addWidget(label_delivery_party, 1, 1)
|
||||
self._parent.row_delivery_party = QLineEdit()
|
||||
self._parent.row_delivery_party.setObjectName('row_delivery_party')
|
||||
self._parent.row_delivery_party.textChanged.connect(
|
||||
lambda: self._parent.update_delivery_party('delivery_party'))
|
||||
grid.addWidget(self._parent.row_delivery_party, 1, 2)
|
||||
|
||||
label_id_number = QLabel(self.tr('ID NUMBER:'))
|
||||
label_id_number.setAlignment(alignCenter)
|
||||
|
@ -708,19 +708,19 @@ class DeliveryPartySelected(QWidget):
|
|||
lambda: self._parent.update_delivery_party('type_vehicle'))
|
||||
grid.addWidget(self._parent.row_type_vehicle, 5, 2)
|
||||
|
||||
label_delivery_men_active = QLabel(self.tr('ACTIVE:'))
|
||||
label_delivery_men_active.setAlignment(alignCenter)
|
||||
label_delivery_men_active.setObjectName('label_delivery_men_active')
|
||||
grid.addWidget(label_delivery_men_active, 6, 1)
|
||||
self._parent.row_delivery_men_active = QCheckBox()
|
||||
self._parent.row_delivery_men_active.setObjectName('row_delivery_men_active')
|
||||
self._parent.row_delivery_men_active.stateChanged.connect(
|
||||
lambda: self._parent.update_delivery_party('delivery_men_active'))
|
||||
grid.addWidget(self._parent.row_delivery_men_active, 6, 2)
|
||||
label_delivery_party_active = QLabel(self.tr('ACTIVE:'))
|
||||
label_delivery_party_active.setAlignment(alignCenter)
|
||||
label_delivery_party_active.setObjectName('label_delivery_party_active')
|
||||
grid.addWidget(label_delivery_party_active, 6, 1)
|
||||
self._parent.row_delivery_party_active = QCheckBox()
|
||||
self._parent.row_delivery_party_active.setObjectName('row_delivery_party_active')
|
||||
self._parent.row_delivery_party_active.stateChanged.connect(
|
||||
lambda: self._parent.update_delivery_party('delivery_party_active'))
|
||||
grid.addWidget(self._parent.row_delivery_party_active, 6, 2)
|
||||
|
||||
vbox_.addLayout(grid)
|
||||
dialog = QuickDialog(self._parent, 'action', widgets=[vbox_])
|
||||
dialog.accepted.connect(self._parent.dialog_delivery_men_accepted)
|
||||
dialog.accepted.connect(self._parent.dialog_delivery_party_accepted)
|
||||
return dialog
|
||||
|
||||
|
||||
|
@ -758,7 +758,7 @@ class DialogTableDeliveryParty(QWidget):
|
|||
self._parent.button_create_delivery_party = CustomButton(
|
||||
id='button_create_delivery_party',
|
||||
parent=self._parent,
|
||||
icon=get_icon('delivery_men'),
|
||||
icon=get_icon('delivery_party'),
|
||||
title=self.tr('CREATE NEW DELIVERY MEN'),
|
||||
name_style='toolbar',
|
||||
method='button_create_delivery_party'
|
||||
|
@ -892,7 +892,7 @@ class Position(QWidget):
|
|||
self._parent = parent
|
||||
|
||||
def get(self):
|
||||
_field = 'position_ask'
|
||||
_field = 'position'
|
||||
_data = {'name': self.tr('POSITION')}
|
||||
return QuickDialog(self._parent, 'action', data=[(_field, _data)])
|
||||
|
||||
|
@ -903,7 +903,7 @@ class Comment(QWidget):
|
|||
self._parent = parent
|
||||
|
||||
def get(self):
|
||||
_field = 'comment_ask'
|
||||
_field = 'comment'
|
||||
_data = {'name': self.tr('COMMENTS'), 'type': 'text'}
|
||||
return QuickDialog(self._parent, 'action', data=[(_field, _data)])
|
||||
|
||||
|
|
|
@ -17,9 +17,10 @@ from .dialogs import (
|
|||
Comment, DialogPayment, DialogSalesman, DialogVoucher, DialogPrintInvoice,
|
||||
DialogGlobalDiscount, DialogPaymentTerm, DialogStock, DialogOrder,
|
||||
DialogForceAssign, DialogTaxes, DialogCancelInvoice, SaleLine, DialogAgent,
|
||||
DialogConsumer, DialogManageTables, DialogDeliveryMen, DialogChannel,
|
||||
DialogTableMoneyCount, DialogGlobalDiscountTable, DeliveryPartySelected,
|
||||
DialogTableDeliveryParty, DialogTableSaleConsumer, SaleConsumerSelected
|
||||
DialogConsumer, DialogManageTables, DialogTableMoneyCount,
|
||||
DialogGlobalDiscountTable, DeliveryPartySelected, DialogTableDeliveryParty,
|
||||
DialogTableSaleConsumer, SaleConsumerSelected, DialogChannel,
|
||||
DialogDeliveryParty,
|
||||
)
|
||||
from .constants import DIALOG_REPLY_YES
|
||||
|
||||
|
@ -246,7 +247,7 @@ class FrontWindow(QMainWindow):
|
|||
self.dialog_product_edit = SaleLine(self).get()
|
||||
self.dialog_table_delivery_party = DialogTableDeliveryParty(self).get()
|
||||
self.dialog_delivery_party_selected = DeliveryPartySelected(self).get()
|
||||
self.dialog_delivery_men = DialogDeliveryMen(self).get()
|
||||
self.dialog_delivery_party = DialogDeliveryParty(self).get()
|
||||
if self._web_channel:
|
||||
self.dialog_channel = DialogChannel(self).get()
|
||||
if self._commission_activated:
|
||||
|
|
|
@ -15,7 +15,7 @@ _directory = os.path.join(os.getenv(home), directory)
|
|||
localfile = os.path.join(_directory, file_db)
|
||||
|
||||
|
||||
class LocalStore(object):
|
||||
class LocalDB(object):
|
||||
def __init__(self, params=None):
|
||||
self.conn = sqlite3.connect(localfile)
|
||||
|
||||
|
@ -138,6 +138,6 @@ class LocalStore(object):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
store = LocalStore()
|
||||
store = LocalDB()
|
||||
store.create_table()
|
||||
store.get_local_products()
|
||||
|
|
|
@ -22,17 +22,19 @@ from app.commons.messages import MessageBar
|
|||
from app.commons.table import TableView
|
||||
from app.commons.model import TableModel, TableModelEdit
|
||||
from app.commons.menu_buttons import MenuDash
|
||||
from .localdb import LocalStore
|
||||
from .localdb import LocalDB
|
||||
from .reporting import Receipt
|
||||
from .buttonpad import ButtonsStacked, ButtonsFunction, StartButtons
|
||||
from .states import STATES, RE_SIGN
|
||||
from .commons.custom_button import CustomButton
|
||||
from .threads import DoInvoice
|
||||
from .store import StoreView
|
||||
from .constants import (
|
||||
PATH_PRINTERS, DELTA_LOCALE, STRETCH, alignRight, alignLeft, alignCenter,
|
||||
alignHCenter, DIALOG_REPLY_NO, ZERO, RATE_CREDIT_LIMIT,
|
||||
CONVERSION_DIGITS, MONEY, MINIMUM_DATE,
|
||||
)
|
||||
from .dialogs import DialogDeliveryParty
|
||||
|
||||
invoice_type = [('P', ('POS'))]
|
||||
|
||||
|
@ -93,6 +95,13 @@ class MainWindow(FrontWindow):
|
|||
self.do_invoice = DoInvoice(self, self._context)
|
||||
self.do_invoice.sigDoInvoice.connect(self.__do_invoice_thread)
|
||||
self.set_state('disabled')
|
||||
sale_fields = [
|
||||
'number', 'party', 'sale_date', 'comment', 'position',
|
||||
'description', 'invoice_number', 'tip_amount', 'delivery_amount',
|
||||
'salesman', 'state', 'kind', 'channel', 'reference',
|
||||
'invoice_type', 'consumer', 'delivery_party',
|
||||
]
|
||||
self.store = StoreView(self, sale_fields)
|
||||
if self.cache_local:
|
||||
self.set_cache_company()
|
||||
self.set_cache_products()
|
||||
|
@ -111,26 +120,26 @@ class MainWindow(FrontWindow):
|
|||
)
|
||||
|
||||
def set_cache_company(self):
|
||||
self.store = LocalStore()
|
||||
self.store.create_table_config()
|
||||
self._local_config = self.store.get_config()
|
||||
self.local_db = LocalDB()
|
||||
self.local_db.create_table_config()
|
||||
self._local_config = self.local_db.get_config()
|
||||
if not self._local_config:
|
||||
company_id = self.device['shop']['company']['id']
|
||||
self._local_config = self.store.set_config([company_id])
|
||||
self._local_config = self.local_db.set_config([company_id])
|
||||
|
||||
def set_cache_products(self):
|
||||
self.store.create_table_product()
|
||||
local_products = self.store.get_local_products()
|
||||
self.local_db.create_table_product()
|
||||
local_products = self.local_db.get_local_products()
|
||||
|
||||
config = self.store.get_config()
|
||||
config = self.local_db.get_config()
|
||||
_sync_date = config[1]
|
||||
products = self.Product.sync_get_products({
|
||||
'write_date': _sync_date,
|
||||
'shop_id': self.ctx['shop']
|
||||
})
|
||||
self.store.update_products(products, local_products)
|
||||
self.local_db.update_products(products, local_products)
|
||||
now = datetime.now()
|
||||
self.store.set_config_sync(str(now))
|
||||
self.local_db.set_config_sync(str(now))
|
||||
|
||||
def set_printers_usb(self, PATH_PRINTERS):
|
||||
for usb_dev in os.listdir(PATH_PRINTERS):
|
||||
|
@ -340,7 +349,6 @@ class MainWindow(FrontWindow):
|
|||
self.menu_control_panel = ButtonsFunction(self, values=values)
|
||||
button_functions = ButtonsFunction(self)
|
||||
|
||||
|
||||
info_fields = [
|
||||
('party', {
|
||||
'name': self.tr('CUSTOMER'),
|
||||
|
@ -349,7 +357,7 @@ class MainWindow(FrontWindow):
|
|||
'size': self.screen_size,
|
||||
'color': self.label_color
|
||||
}),
|
||||
('date', {
|
||||
('sale_date', {
|
||||
'name': self.tr('DATE'),
|
||||
'readonly': True,
|
||||
'placeholder': False,
|
||||
|
@ -363,7 +371,7 @@ class MainWindow(FrontWindow):
|
|||
'size': self.screen_size,
|
||||
'color': self.label_color
|
||||
}),
|
||||
('order_number', {
|
||||
('number', {
|
||||
'name': self.tr('No ORDER'),
|
||||
'placeholder': False,
|
||||
'readonly': True,
|
||||
|
@ -378,7 +386,7 @@ class MainWindow(FrontWindow):
|
|||
'size': self.screen_size,
|
||||
'color': self.label_color
|
||||
}),
|
||||
('delivery_men', {
|
||||
('delivery_party', {
|
||||
'name': self.tr('DELIVERY MEN'),
|
||||
'placeholder': False,
|
||||
'size': self.screen_size,
|
||||
|
@ -509,14 +517,12 @@ class MainWindow(FrontWindow):
|
|||
'type': 'money',
|
||||
'size': self.screen_size,
|
||||
'color': self.label_color,
|
||||
'editable': True,
|
||||
}),
|
||||
('delivery_amount', {
|
||||
'name': self.tr('VR. DOMIC'),
|
||||
'type': 'money',
|
||||
'size': self.screen_size,
|
||||
'color': self.label_color,
|
||||
'editable': True,
|
||||
}),
|
||||
('total_amount', {
|
||||
'name': self.tr('TOTAL'),
|
||||
|
@ -634,6 +640,7 @@ class MainWindow(FrontWindow):
|
|||
|
||||
def change_view_to(self, to_view):
|
||||
if to_view == 'start_front':
|
||||
self.store.clear()
|
||||
self.order_front.hide()
|
||||
self.start_front.show()
|
||||
else:
|
||||
|
@ -934,7 +941,7 @@ class MainWindow(FrontWindow):
|
|||
|
||||
self.set_amounts(res)
|
||||
self._sale['number'] = res['number']
|
||||
self.field_order_number.setText(self._sale['number'])
|
||||
self.field_number.setText(self._sale['number'])
|
||||
|
||||
self.field_invoice.setText(res['invoice_number'])
|
||||
self.field_amount.setText('')
|
||||
|
@ -994,10 +1001,10 @@ class MainWindow(FrontWindow):
|
|||
return
|
||||
self.dialog_salesman.exec_()
|
||||
|
||||
def action_delivery_men(self):
|
||||
self.dialog_delivery_men.exec_()
|
||||
def action_delivery_party(self):
|
||||
self.dialog_delivery_party.exec_()
|
||||
|
||||
def action_delivery_men_panel(self):
|
||||
def action_delivery_party_panel(self):
|
||||
self.dialog_control_panel.close()
|
||||
self.dialog_table_delivery_party.exec_()
|
||||
|
||||
|
@ -1099,17 +1106,8 @@ class MainWindow(FrontWindow):
|
|||
# self._PosSale.write([self._sale['id']], {'salesman': self.field_salesman_id})
|
||||
|
||||
def on_change_input(self, field, value):
|
||||
if field == 'tip_amount':
|
||||
data = {
|
||||
'tip_amount': value
|
||||
}
|
||||
else:
|
||||
data = {
|
||||
'delivery_amount': value
|
||||
}
|
||||
if self._sale.get('id') and value is not None:
|
||||
res = self.Sale.write([self._sale['id']], data)
|
||||
self.set_amounts(res)
|
||||
res = self.store.update({field: value})
|
||||
self.set_amounts(res)
|
||||
|
||||
def action_delivery_charge_selection_changed(self, index):
|
||||
val = self.field_delivery_charge.get_id()
|
||||
|
@ -1118,8 +1116,7 @@ class MainWindow(FrontWindow):
|
|||
|
||||
def action_kind_selection_changed(self, index):
|
||||
val = self.field_kind.get_id()
|
||||
if val:
|
||||
self.Sale.write([self._sale['id']], {'kind': val})
|
||||
self.store.update({'kind': val})
|
||||
|
||||
def action_invoice_type_selection_changed(self, index):
|
||||
val = self.field_invoice_type.get_id()
|
||||
|
@ -1143,7 +1140,7 @@ class MainWindow(FrontWindow):
|
|||
def action_print_sale(self):
|
||||
number = self.field_invoice.text()
|
||||
if not number:
|
||||
number = self.field_order_number.text()
|
||||
number = self.field_number.text()
|
||||
if number:
|
||||
self.field_invoice_number_ask.setText(number)
|
||||
res = self.dialog_print_invoice.exec_()
|
||||
|
@ -1194,16 +1191,14 @@ class MainWindow(FrontWindow):
|
|||
|
||||
def action_comment(self):
|
||||
self.dialog_comment.exec_()
|
||||
comment = self.field_comment_ask.toPlainText()
|
||||
comment = self.field_comment.toPlainText()
|
||||
if comment:
|
||||
self.Sale.write([self._sale['id']], {'comment': comment})
|
||||
|
||||
def action_position(self):
|
||||
self.dialog_position.exec_()
|
||||
position = self.field_position_ask.text()
|
||||
if hasattr(self, 'field_position') and position:
|
||||
self.field_position.setText(position)
|
||||
self.Sale.write([self._sale['id']], {'position': position})
|
||||
position = self.field_position.text()
|
||||
self.store.update({'position': position})
|
||||
|
||||
def action_agent(self):
|
||||
self.dialog_agent.exec_()
|
||||
|
@ -1271,7 +1266,7 @@ class MainWindow(FrontWindow):
|
|||
}
|
||||
orders, sale_number = self.Sale.get_order2print(args)
|
||||
self._sale['number'] = sale_number
|
||||
self.field_order_number.setText(self._sale['number'])
|
||||
self.field_number.setText(self._sale['number'])
|
||||
result = self.receipt_order.print_orders(orders, reversion, kind)
|
||||
except:
|
||||
logging.error('Printing order fail!')
|
||||
|
@ -1466,32 +1461,35 @@ class MainWindow(FrontWindow):
|
|||
self.clear_data()
|
||||
self.clear_left_panel()
|
||||
self.clear_right_panel()
|
||||
self.store.clear()
|
||||
sale, = self.Sale.find([('id', '=', sale_id)])
|
||||
self.store.set_sale(sale['id'])
|
||||
self.store.set(sale)
|
||||
self._sale.update(sale)
|
||||
self.table_payment_lines.reset()
|
||||
self.field_order_number.setText(sale['number'] or '')
|
||||
self.field_state.setText(sale['state'] or '')
|
||||
self._set_sale_date()
|
||||
|
||||
if hasattr(self, 'field_position'):
|
||||
self.field_position.setText(sale['position'] or '')
|
||||
if sale.get('payment_term'):
|
||||
self.field_payment_term_id = sale['payment_term']['id']
|
||||
self.field_payment_term.setText(sale['payment_term']['name'] or '')
|
||||
if sale.get('salesman'):
|
||||
self.field_salesman.setText(sale['salesman']['name'] or '')
|
||||
self.field_salesman_id = sale['salesman']['id']
|
||||
# self.field_number.setText(sale['number'] or '')
|
||||
# self.field_state.setText(sale['state'] or '')
|
||||
# if hasattr(self, 'field_position'):
|
||||
# self.field_position.setText(sale['position'] or '')
|
||||
# if sale.get('payment_term'):
|
||||
# self.field_payment_term_id = sale['payment_term']['id']
|
||||
# self.field_payment_term.setText(sale['payment_term']['name'] or '')
|
||||
# if sale.get('salesman'):
|
||||
# self.field_salesman.setText(sale['salesman']['name'] or '')
|
||||
# self.field_salesman_id = sale['salesman']['id']
|
||||
|
||||
if sale.get('invoice_type'):
|
||||
self.field_invoice_type.set_from_id(sale['invoice_type'])
|
||||
|
||||
if sale.get('comment'):
|
||||
self.field_comment_ask.setText(sale['comment'])
|
||||
|
||||
if sale.get('invoice_number'):
|
||||
self.field_invoice.setText(sale['invoice_number'] or '')
|
||||
else:
|
||||
self.field_invoice.setText('')
|
||||
# if sale.get('invoice_type'):
|
||||
# self.field_invoice_type.set_from_id(sale['invoice_type'])
|
||||
#
|
||||
# if sale.get('comment'):
|
||||
# self.field_comment.setText(sale['comment'])
|
||||
#
|
||||
# if sale.get('invoice_number'):
|
||||
# self.field_invoice.setText(sale['invoice_number'] or '')
|
||||
# else:
|
||||
# self.field_invoice.setText('')
|
||||
if self.field_delivery_charge:
|
||||
self.field_delivery_charge.set_enabled(True)
|
||||
if sale.get('delivery_charge'):
|
||||
|
@ -1507,24 +1505,24 @@ class MainWindow(FrontWindow):
|
|||
('id', '=', consumer['id']),
|
||||
])
|
||||
|
||||
if sale.get('channel'):
|
||||
self.field_channel.setText(sale['channel']['rec_name'].upper())
|
||||
# if sale.get('channel'):
|
||||
# self.field_channel.setText(sale['channel']['rec_name'].upper())
|
||||
|
||||
tip_amount = sale.get('tip_amount')
|
||||
if tip_amount:
|
||||
self.field_tip_amount.setText(tip_amount)
|
||||
# tip_amount = sale.get('tip_amount')
|
||||
# if tip_amount:
|
||||
# self.field_tip_amount.setText(tip_amount)
|
||||
#
|
||||
# delivery_amount = sale.get('delivery_amount')
|
||||
# if delivery_amount:
|
||||
# self.field_delivery_amount.setText(delivery_amount)
|
||||
|
||||
delivery_amount = sale.get('delivery_amount')
|
||||
if delivery_amount:
|
||||
self.field_delivery_amount.setText(delivery_amount)
|
||||
# kind = sale.get('kind') or ''
|
||||
# self.field_kind.set_from_id(kind)
|
||||
|
||||
kind = sale.get('kind') or ''
|
||||
self.field_kind.set_from_id(kind)
|
||||
|
||||
delivery_party = sale.get('delivery_party') or ''
|
||||
if delivery_party:
|
||||
delivery_party = delivery_party['name']
|
||||
self.field_delivery_men.setText(delivery_party)
|
||||
# delivery_party = sale.get('delivery_party') or ''
|
||||
# if delivery_party:
|
||||
# delivery_party = delivery_party['name']
|
||||
# self.field_delivery_party.setText(delivery_party)
|
||||
|
||||
self.field_change.zero()
|
||||
if self._commission_activated:
|
||||
|
@ -1550,8 +1548,9 @@ class MainWindow(FrontWindow):
|
|||
self.table_payment_lines.record_add(payment)
|
||||
|
||||
self.set_state('add')
|
||||
# ?????
|
||||
self.party_id = sale['party']['id']
|
||||
self.field_party.setText(sale['party']['name'])
|
||||
#
|
||||
self.set_amounts(sale)
|
||||
self.set_amount_received()
|
||||
self.field_amount.setText('')
|
||||
|
@ -1626,7 +1625,7 @@ class MainWindow(FrontWindow):
|
|||
['button_closed', self.tr('CLOSED STATEMENTS'), 'action_closed_statement'],
|
||||
# ['button_money', self.tr('COUNT MONEY'), 'action_count_money'],
|
||||
['button_discount', self.tr('GLOBAL DISCOUNT'), 'action_table_discount'],
|
||||
['button_delivery_men', self.tr('DELIVERY MEN'), 'action_delivery_men_panel'],
|
||||
['button_delivery_party', self.tr('DELIVERY MEN'), 'action_delivery_party_panel'],
|
||||
['button_help', self.tr('HELP'), 'action_help'],
|
||||
]
|
||||
return menu_dash
|
||||
|
@ -1724,13 +1723,14 @@ class MainWindow(FrontWindow):
|
|||
self.dialog_global_discount_table.close()
|
||||
self.dialog_control_panel.close()
|
||||
|
||||
def on_selected_delivery_men(self, delivery_men_id):
|
||||
if delivery_men_id:
|
||||
self.Sale.write([self._sale['id']], {'delivery_party': delivery_men_id})
|
||||
sale, = self.Sale.find([('id', '=', self._sale['id'])])
|
||||
self.field_delivery_men.setText(sale['delivery_party']['name'] or '')
|
||||
self.field_delivery_men_id = delivery_men_id
|
||||
self.dialog_delivery_men.close()
|
||||
def on_selected_delivery_party(self, delivery_party_id):
|
||||
if delivery_party_id:
|
||||
# self.Sale.write([self._sale['id']], {'delivery_party': delivery_party_id})
|
||||
# sale, = self.Sale.find([('id', '=', self._sale['id'])])
|
||||
# self.field_delivery_party.setText(sale['delivery_party']['name'] or '')
|
||||
# self.field_delivery_party_id = delivery_party_id
|
||||
self.store.update({'delivery_party': delivery_party_id})
|
||||
self.dialog_delivery_party.close()
|
||||
|
||||
def on_selected_payment_term(self, payterm_id):
|
||||
if payterm_id:
|
||||
|
@ -1784,7 +1784,7 @@ class MainWindow(FrontWindow):
|
|||
|
||||
if self.cache_local:
|
||||
domain = [clause]
|
||||
products = self.store.find_product_elastic(domain, limit=100)
|
||||
products = self.local_db.find_product_elastic(domain, limit=100)
|
||||
else:
|
||||
fields = self.dialog_search_products.fields_names
|
||||
products = self.Product.find(domain, fields=fields,
|
||||
|
@ -1829,10 +1829,10 @@ class MainWindow(FrontWindow):
|
|||
self.field_agent_id = None
|
||||
self.field_payment_term_id = self.default_payment_term['id']
|
||||
self.field_payment_term.setText(self.default_payment_term['name'])
|
||||
self.field_date.setText('')
|
||||
self.field_sale_date.setText('')
|
||||
self.field_global_discount_ask.setText('')
|
||||
self.field_amount.setText('')
|
||||
self.field_order_number.setText('')
|
||||
self.field_number.setText('')
|
||||
self.field_state.setText('')
|
||||
self.current_comment = ''
|
||||
if hasattr(self, 'field_consumer'):
|
||||
|
@ -1841,8 +1841,8 @@ class MainWindow(FrontWindow):
|
|||
self.field_delivery_charge.set_from_id('')
|
||||
if self.field_table_assigned:
|
||||
self.field_table_assigned.setText('')
|
||||
if hasattr(self, 'field_comment_ask'):
|
||||
self.field_comment_ask.document().clear()
|
||||
if hasattr(self, 'field_comment'):
|
||||
self.field_comment.document().clear()
|
||||
if hasattr(self, 'field_points'):
|
||||
self.field_points.setText('')
|
||||
if self._commission_activated and hasattr(self, 'field_agent'):
|
||||
|
@ -1850,9 +1850,9 @@ class MainWindow(FrontWindow):
|
|||
self.field_agent_ask.setText('')
|
||||
self.field_commission_ask.setText('')
|
||||
self.field_commission_amount.setText('')
|
||||
if hasattr(self, 'field_position'):
|
||||
self.field_position.setText('')
|
||||
self.field_position_ask.setText('')
|
||||
# if hasattr(self, 'field_position'):
|
||||
# self.field_position.setText('')
|
||||
# self.field_position.setText('')
|
||||
self.model_sale_lines.reset()
|
||||
self.clear_input_text()
|
||||
self.clear_amount_text()
|
||||
|
@ -1890,6 +1890,7 @@ class MainWindow(FrontWindow):
|
|||
self.message_bar.set('not_sale')
|
||||
# self.state_disabled()
|
||||
return
|
||||
self.store.clear()
|
||||
self.set_state('add')
|
||||
self.input_text_changed('')
|
||||
self.amount_text_changed('0')
|
||||
|
@ -1913,28 +1914,31 @@ class MainWindow(FrontWindow):
|
|||
'payment_term': self.default_payment_term['id'],
|
||||
'kind': kind,
|
||||
})
|
||||
self.store.set(self._sale)
|
||||
print('NUEVA VENTA self._sale ', self._sale)
|
||||
self.field_party.setText(self._sale['party_name'])
|
||||
self.field_invoice_type.set_from_id(self._sale['invoice_type'])
|
||||
self.field_state.setText(self._sale['state'])
|
||||
self.field_comment_ask.clear()
|
||||
# self.field_comment.clear()
|
||||
self.field_voucher_ask.setText('')
|
||||
# FIXME ADD MORE
|
||||
self._sale.update({
|
||||
'total_amount': 0
|
||||
})
|
||||
if hasattr(self, 'field_channel'):
|
||||
self.field_channel.setText('')
|
||||
# self.field_state.setText(self._sale['state'])
|
||||
# if hasattr(self, 'field_channel'):
|
||||
# self.field_channel.setText('')
|
||||
if hasattr(self, 'field_kind'):
|
||||
print(type(self.field_kind))
|
||||
if not kind:
|
||||
kind = ''
|
||||
self.field_kind.set_from_id(kind)
|
||||
if hasattr(self, 'field_delivery_men'):
|
||||
self.field_delivery_men.setText('')
|
||||
if hasattr(self, 'field_delivery_party'):
|
||||
self.field_delivery_party.setText('')
|
||||
|
||||
self.party_id = self.default_party['id']
|
||||
if self._sale.get('id'):
|
||||
self._set_sale_date()
|
||||
self.field_order_number.setText(self._sale['number'])
|
||||
if self._sale.get('id') and self.field_delivery_charge:
|
||||
# self._set_sale_date()
|
||||
# self.field_number.setText(self._sale['number'])
|
||||
if self.field_delivery_charge:
|
||||
self.field_delivery_charge.set_enabled(True)
|
||||
self.change_view_to('order_front')
|
||||
|
@ -1946,7 +1950,7 @@ class MainWindow(FrontWindow):
|
|||
local_date = self._sale['sale_date']
|
||||
if isinstance(local_date, date):
|
||||
local_date = local_date.isoformat()
|
||||
self.field_date.setText(local_date)
|
||||
self.field_sale_date.setText(local_date)
|
||||
|
||||
def _search_product(self, code):
|
||||
domain = [
|
||||
|
@ -1961,7 +1965,7 @@ class MainWindow(FrontWindow):
|
|||
('barcode', '=', '%{:}%'.format(code)),
|
||||
('code', '=', '%{:}%'.format(code))]
|
||||
domain = [clause]
|
||||
products = self.store.find_product_elastic(domain, limit=100)
|
||||
products = self.local_db.find_product_elastic(domain, limit=100)
|
||||
else:
|
||||
products = self.Product.find(domain, ctx=self.stock_context)
|
||||
|
||||
|
@ -2092,24 +2096,24 @@ class MainWindow(FrontWindow):
|
|||
|
||||
def clear_delivery_party(self):
|
||||
self._delivery_party_selected = None
|
||||
self.row_delivery_men.setText('')
|
||||
self.row_delivery_party.setText('')
|
||||
self.row_id_number.setText('')
|
||||
self.row_phone.setText('')
|
||||
self.row_number_plate.setText('')
|
||||
self.row_type_vehicle.set_from_id('')
|
||||
self.row_delivery_men_active.setChecked(True)
|
||||
self.row_delivery_party_active.setChecked(True)
|
||||
|
||||
def delivery_party_selected(self, data):
|
||||
# return
|
||||
self._delivery_party_selected = data['id']
|
||||
self.row_delivery_men.setText(data['rec_name'])
|
||||
self.row_delivery_party.setText(data['rec_name'])
|
||||
self.row_id_number.setText(data['party']['id_number'])
|
||||
self.row_number_plate.setText(data['number_plate'])
|
||||
if data.get('type_vehicle'):
|
||||
self.row_type_vehicle.set_from_id(data['type_vehicle'])
|
||||
self.row_delivery_men_active.setChecked(data['active'])
|
||||
self.row_delivery_party_active.setChecked(data['active'])
|
||||
self.dialog_delivery_party_selected.show()
|
||||
self.row_delivery_men_active.setFocus()
|
||||
self.row_delivery_party_active.setFocus()
|
||||
|
||||
def setup_money_count(self):
|
||||
self.model_money_count = TableModelEdit(self, MONEY)
|
||||
|
@ -2282,6 +2286,7 @@ class MainWindow(FrontWindow):
|
|||
self.model_delivery_party = TableModel('sale.delivery_party', self.fields_delivery_party)
|
||||
for record in self.delivery_man_table:
|
||||
self.model_delivery_party.add_record(record)
|
||||
self.delivery_parties = [d for d in self.model_delivery_party._data if d['active']]
|
||||
|
||||
def setup_payment(self):
|
||||
pay_fields = [{
|
||||
|
@ -2646,7 +2651,7 @@ class MainWindow(FrontWindow):
|
|||
if res.get('party'):
|
||||
self.on_selected_party(res['party'])
|
||||
|
||||
def dialog_delivery_men_accepted(self):
|
||||
def dialog_delivery_party_accepted(self):
|
||||
if not self.state_delivery_party:
|
||||
return
|
||||
if hasattr(self, '_delivery_party_selected') and self._delivery_party_selected:
|
||||
|
@ -2663,12 +2668,12 @@ class MainWindow(FrontWindow):
|
|||
})
|
||||
self.model_delivery_party.add_record(res)
|
||||
|
||||
self.delivery_man = [d for d in self.model_delivery_party._data if d['active']]
|
||||
self.dialog_delivery_men = DialogDeliveryMen(self).get()
|
||||
self.delivery_parties = [d for d in self.model_delivery_party._data if d['active']]
|
||||
self.dialog_delivery_party = DialogDeliveryParty(self).get()
|
||||
|
||||
def update_delivery_party(self, field=''):
|
||||
if field == 'delivery_men':
|
||||
self.state_delivery_party['party'] = self.row_delivery_men.text()
|
||||
if field == 'delivery_party':
|
||||
self.state_delivery_party['party'] = self.row_delivery_party.text()
|
||||
if field == 'row_phone':
|
||||
self.state_delivery_party['phone'] = self.row_phone.text()
|
||||
if field == 'id_number':
|
||||
|
@ -2677,8 +2682,8 @@ class MainWindow(FrontWindow):
|
|||
self.state_delivery_party['number_plate'] = self.row_number_plate.text()
|
||||
if field == 'type_vehicle':
|
||||
self.state_delivery_party['type_vehicle'] = self.row_type_vehicle.get_id()
|
||||
if field == 'delivery_men_active':
|
||||
self.state_delivery_party['active'] = self.row_delivery_men_active.isChecked()
|
||||
if field == 'delivery_party_active':
|
||||
self.state_delivery_party['active'] = self.row_delivery_party_active.isChecked()
|
||||
|
||||
def update_consumer_data(self, field=''):
|
||||
if field == 'notes':
|
||||
|
@ -2789,3 +2794,5 @@ class MainWindow(FrontWindow):
|
|||
if self._consumer.get('birthday'):
|
||||
y, m, d = self._consumer['birthday'].split('-')
|
||||
self.row_field_birthday.setDate(QDate(int(y), int(m), int(d)))
|
||||
|
||||
# 2798
|
||||
|
|
|
@ -29,7 +29,6 @@ button_style_1 = """
|
|||
class MixButton(QWidget):
|
||||
def __init__(self, value, activate_method, see_sale_method):
|
||||
super(MixButton, self).__init__()
|
||||
print('Value ', value)
|
||||
self.name = value['name']
|
||||
self.table_id = value['id']
|
||||
self.set_data(value)
|
||||
|
|
|
@ -36,7 +36,7 @@ MODELS = {
|
|||
'channel', 'channel.rec_name', 'delivery_way', 'consumer',
|
||||
'delivery_state', 'table_assigned', 'invoice_type', 'kind',
|
||||
'comment', 'net_amount', 'tip_amount', 'delivery_amount',
|
||||
'net_amount',
|
||||
'net_amount', 'party.rec_name',
|
||||
]
|
||||
},
|
||||
'sale.line': {
|
||||
|
@ -139,7 +139,7 @@ MODELS = {
|
|||
'show_brand', 'show_delivery_charge', 'decimals_digits_quantity',
|
||||
'password_admin_pos', 'show_fractions', 'discount_pos_method',
|
||||
'new_sale_automatic', 'default_invoice_type', 'cache_products_local',
|
||||
'print_invoice_payment', 'delivery_product',
|
||||
'print_invoice_payment', 'delivery_product', 'delivery_party',
|
||||
'delivery_product.list_price',
|
||||
]
|
||||
},
|
||||
|
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
@ -0,0 +1,69 @@
|
|||
import os
|
||||
from app.commons.forms import ComboBox
|
||||
|
||||
|
||||
class StoreView(object):
|
||||
"""
|
||||
Class for that all changes in store data update view fields
|
||||
"""
|
||||
|
||||
def __init__(self, parent, fields):
|
||||
self.parent = parent
|
||||
self.Sale = parent.Sale
|
||||
self.store = {f: None for f in fields}
|
||||
|
||||
def set_sale(self, sale_id):
|
||||
self.sale_id = sale_id
|
||||
|
||||
def get(self, field_name):
|
||||
field = self.store[field_name]
|
||||
return field
|
||||
|
||||
def clear(self):
|
||||
self.sale_id = None
|
||||
for k, v in self.store.items():
|
||||
field = getattr(self.parent, 'field_' + k, None)
|
||||
if field and hasattr(field, 'setText'):
|
||||
field.setText('')
|
||||
|
||||
field_ask = getattr(self.parent, 'field_' + k + '_ask', None)
|
||||
if field_ask and hasattr(field_ask, 'setText'):
|
||||
field_ask.setText('')
|
||||
|
||||
self.store[k] = None
|
||||
|
||||
def set(self, values):
|
||||
if values.get('id'):
|
||||
self.sale_id = values['id']
|
||||
for k, v in values.items():
|
||||
self.store[k] = v
|
||||
field = getattr(self.parent, 'field_' + k, None)
|
||||
if field and hasattr(field, 'setText'):
|
||||
if isinstance(v, dict):
|
||||
val = v.get('rec_name') or v.get('name')
|
||||
elif v is None:
|
||||
val = ''
|
||||
else:
|
||||
val = v
|
||||
field.setText(str(val))
|
||||
elif isinstance(field, ComboBox):
|
||||
field.set_from_id(v)
|
||||
|
||||
def update(self, values):
|
||||
"""
|
||||
This method update record in database and current view
|
||||
values: Dict
|
||||
"""
|
||||
print('------------------', self.sale_id, values)
|
||||
for k, v in values.items():
|
||||
self.store[k] = v
|
||||
field = getattr(self.parent, 'field_' + k)
|
||||
if hasattr(field, 'setText'):
|
||||
if isinstance(v, dict):
|
||||
val = v['rec_name']
|
||||
else:
|
||||
val = v
|
||||
field.setText(str(val))
|
||||
print()
|
||||
res = self.Sale.write([self.sale_id], values)
|
||||
return res
|
Loading…
Reference in New Issue