Merge branch 'master' of bitbucket.org:presik/presik_pos

This commit is contained in:
Oscar Alvarez 2020-07-06 07:59:30 -05:00
commit 5b86b3f2fe
10 changed files with 807 additions and 733 deletions

View File

@ -58,7 +58,14 @@ class Completer(QCompleter):
for r in records:
row = []
for key in vkeys:
row.append(r[key])
if '.' in key:
attrs = key.split('.')
val = r.copy()
for a in attrs:
val = val[a]
else:
val = r[key]
row.append(val)
values.append(row)
return values
@ -106,8 +113,8 @@ class Field(QLineEdit):
self.set_completer(value.get('model'), value.get('fields'),
value.get('domain'))
def set_completer(self, tryton_model, fields, domain=[]):
records = tryton_model.find(domain)
def set_completer(self, model, fields, domain=[]):
records = model.find(domain)
self.completer = Completer(self.parent, records, fields)
self.setCompleter(self.completer)

View File

@ -443,7 +443,7 @@ class TableModel(QAbstractTableModel):
matchers = [t.lower() for t in searchText.split(' ')]
self.filteredItems = []
for item in self.currentItems:
values = item.values()
values = list(item.values())
values.pop(0)
values_clear = list(filter(None, values))
exists = all(mt in ''.join(values_clear).lower() for mt in matchers)

View File

@ -2,7 +2,7 @@
QAbstractButton {
font-family: "DejaVu Sans";
border-style: groove;
font: 22pt;
font: 18pt;
color: rgb(102, 102, 102);
background-color: rgb(242, 242, 242);
min-height: 45px;
@ -23,38 +23,38 @@ QAbstractButton {
}
#field_default {
font : 26px;
font : 22px;
}
#field_large_gray, #label_large_gray {
font : 26px;
font : 22px;
color : rgb(54, 54, 54);
}
#field_large_blue, #label_large_blue {
font : 26px;
font : 22px;
color : rgb(0, 30, 80);
}
#field_large_orange, #label_large_orange {
font : 26px;
font : 22px;
color : rgb(235, 160, 15);
}
#label_qty, #spin_box_qty, #row_field_price,
#label_price, #row_field_note, #label_fraction, #row_field_qty,
#field_fraction {
font : 26px;
font : 22px;
alignment : center;
}
#row_field_description {
font : 26px;
font : 22px;
color : #242424;
}
#label_product {
font : bold 24px;
font : bold 20px;
alignment : center;
color : #242424;
}
@ -85,14 +85,14 @@ QSpinBox::down-button {
#label_position, #label_salesman, #label_payment_term,
#label_party, #label_global_discount, #field_invoice, #label_invoice,
#label_agent, #label_date, #label_order_number, #label_default {
font : 26px;
font : 22px;
color : rgb(150, 150, 150);
min-height : 10px;
min-width : 10px;
}
#field_amount, #field_sign {
font : bold 48px;
font : bold 42px;
color : rgb(43, 60, 77);
min-height : 40px;
max-height : 100px;
@ -114,13 +114,13 @@ QSpinBox::down-button {
#table_payment {
color : rgb(70, 70, 70);
font : 14pt;
font : 12pt;
max-height : 80px;
}
#table_sale_lines {
color : rgb(70, 70, 70);
font : 14pt;
font : 12pt;
}
#label_paid, #label_change, #label_discount, #label_total_amount,
@ -128,7 +128,7 @@ QSpinBox::down-button {
#field_total_amount, #field_change, #field_discount, #field_paid,
#field_untaxed_amount, #field_taxes_amount {
min-height : 10px;
font: bold 20pt;
font: bold 16pt;
}
#img_pixmap_pos {

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -317,7 +317,7 @@ class MainWindow(FrontWindow):
if self._commission_activated:
_PosSale['fields'].extend(['agent', 'agent.party.name', 'commission'])
modules.set_models([_Agent, _Commission])
# modules.set_models([_Agent, _Commission])
self.User = FastModel('res.user', self.ctx)
self._user, = self.User.find([('login', '=', self.user)])
@ -338,6 +338,9 @@ class MainWindow(FrontWindow):
self.Party = FastModel('party.party', self.ctx)
self.Taxes = FastModel('account.tax', self.ctx)
self.ActionReport = FastModel('ir.action.report', self.ctx)
if self._commission_activated:
self.Agent = FastModel('commission.agent', self.ctx)
self.Comission = FastModel('commission', self.ctx)
models_to_work = [_PosSale]
@ -507,6 +510,33 @@ class MainWindow(FrontWindow):
left_head.addWidget(self.field_amount, 0)
info_fields = [
('invoice_type', {
'name': self.tr('INVOICE TYPE'),
'placeholder': False,
'type': 'selection',
'on_change': 'action_invoice_type_selection_changed',
'values': [
('', ''),
('C', self.tr('COMPUTADOR')),
('M', self.tr('MANUAL')),
('P', self.tr('POS')),
('1', self.tr('VENTA ELECTRONICA')),
('2', self.tr('VENTA DE EXPORTACION')),
# ('3', self.tr('FACTURA POR CONTINGENCIA FACTURADOR')),
# ('4', self.tr('FACTURA POR CONTINGENCIA DIAN')),
('91', self.tr('NOTA CREDITO ELECTRONICA')),
('92', self.tr('NOTA DEBITO ELECTRONICA')),
],
'size': self.screen_size,
'color': 'gray'
}),
('state', {
'name': self.tr('STATE'),
'readonly': True,
'placeholder': False,
'size': self.screen_size,
'color': 'gray'
}),
('party', {
'name': self.tr('CUSTOMER'),
'readonly': True,
@ -528,6 +558,13 @@ class MainWindow(FrontWindow):
'size': self.screen_size,
'color': 'gray'
}),
('order_number', {
'name': self.tr('No ORDER'),
'placeholder': False,
'readonly': True,
'size': self.screen_size,
'color': 'gray'
}),
('payment_term', {
'name': self.tr('PAYMENT TERM'),
'readonly': True,
@ -536,35 +573,9 @@ class MainWindow(FrontWindow):
'size': self.screen_size,
'color': 'gray'
}),
('order_number', {
'name': self.tr('No ORDER'),
'placeholder': False,
'readonly': True,
'size': self.screen_size,
'color': 'gray'
}),
('invoice_type', {
'name': self.tr('INVOICE TYPE'),
'placeholder': False,
'type': 'selection',
'on_change': 'action_invoice_type_selection_changed',
'values': [
('', ''),
('C', self.tr('COMPUTADOR')),
('M', self.tr('MANUAL')),
('P', self.tr('POS')),
('1', self.tr('VENTA ELECTRONICA')),
('2', self.tr('VENTA DE EXPORTACION')),
('3', self.tr('FACTURA POR CONTINGENCIA FACTURADOR')),
('4', self.tr('FACTURA POR CONTINGENCIA DIAN')),
('91', self.tr('NOTA CREDITO ELECTRONICA')),
('92', self.tr('NOTA DEBITO ELECTRONICA')),
],
'size': self.screen_size,
'color': 'gray'
}),
]
self.field_invoice_type = None
self.field_state = None
if self.tablet_mode or self._config['show_position_pos']:
info_fields.append(('position', {
@ -956,7 +967,7 @@ class MainWindow(FrontWindow):
try:
if self.print_receipt == 'automatic':
_copies = self.device['shop.invoice_copies']
_copies = self.device['shop']['invoice_copies']
if not is_credit:
self.print_invoice(copies=_copies)
if self.print_order and self.print_auto_order:
@ -993,6 +1004,7 @@ class MainWindow(FrontWindow):
return
if not self.validate_payment_term():
return
self.field_invoice_type.set_enabled(False)
sale_id = self._sale['id']
res, msg = self.ModSale.faster_process({'sale_id': sale_id})
# Remove deprecation res['res']
@ -1053,6 +1065,8 @@ class MainWindow(FrontWindow):
self.update_total_amount()
def action_salesman(self):
if self._state in ['accept', 'cash']:
return
self.dialog_salesman.exec_()
def action_tax(self):
@ -1228,10 +1242,10 @@ class MainWindow(FrontWindow):
self.field_agent_id = self.field_agent_ask.get_id()
if self.field_agent_id and commission:
agent, = self._Agent.find([
agent, = self.Agent.find([
('id', '=', self.field_agent_id),
])
if commission <= agent['plan.percentage']:
if commission <= agent['plan']['percentage']:
self._PosSale.write([self._sale['id']], {
'agent': self.field_agent_id,
'commission': int(commission),
@ -1251,10 +1265,14 @@ class MainWindow(FrontWindow):
self.field_commission_amount.setText(str(total))
def action_party(self):
if self._state in ['accept', 'cash']:
return
self.dialog_search_parties.clear_rows()
self.dialog_search_parties.execute()
def action_global_discount(self, sale_id=None):
if self._state in ['accept', 'cash']:
return
self.dialog_global_discount.exec_()
discount = self.field_global_discount_ask.text()
if discount and discount.isdigit():
@ -1303,6 +1321,8 @@ class MainWindow(FrontWindow):
self.dialog_payment_term.exec_()
def action_new_sale(self):
if self._state in ['accept', 'cash']:
return
if not self._sale['id']:
return
if self._ask_new_sale():
@ -1358,6 +1378,8 @@ class MainWindow(FrontWindow):
self.dialog_search_products.show()
def action_search_sale(self):
if self._state in ['accept', 'cash']:
return
delta = str(datetime.now() - timedelta(4))
if self.type_pos_user == 'cashier':
dom = ['OR', [
@ -1453,6 +1475,7 @@ class MainWindow(FrontWindow):
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 '')
@ -1473,8 +1496,8 @@ class MainWindow(FrontWindow):
self.field_invoice.setText('')
if self.field_delivery_charge:
self.field_delivery_charge.set_enabled(True)
if self._sale.get('delivery_charge'):
self.field_delivery_charge.set_from_id(self._sale['delivery_charge'])
if sale.get('delivery_charge'):
self.field_delivery_charge.set_from_id(sale['delivery_charge'])
if sale.get('table_assigned'):
self.field_table_assigned.setText(sale['table_assigned.name'] or '')
@ -1899,11 +1922,11 @@ class MainWindow(FrontWindow):
('agent_ask', {
'name': self.tr('AGENT'),
'type': 'relation',
'model': self._Agent,
'domain': [('active', '=', True)],
'model': self.Agent,
'domain': [],
'fields': [
('id', self.tr('ID')),
('party.name', self.tr('NAME')),
('party.rec_name', self.tr('NAME')),
('party.id_number', self.tr('ID NUMBER')),
]}),
('commission_ask', {'name': self.tr('COMMISSION')}),
@ -1945,6 +1968,7 @@ class MainWindow(FrontWindow):
self.field_global_discount_ask.setText('')
self.field_amount.zero()
self.field_order_number.setText('')
self.field_state.setText('')
self.current_comment = ''
if self.field_delivery_charge:
self.field_delivery_charge.set_from_id('')
@ -2004,6 +2028,7 @@ class MainWindow(FrontWindow):
self.payment_ctx = {}
self.is_clear_right_panel = False
self.table_sale_lines.setEnabled(True)
self.field_invoice_type.set_enabled(True)
self.clear_data()
self.clear_left_panel()
self._sale = self._PosSale.new_sale([], {
@ -2014,8 +2039,9 @@ class MainWindow(FrontWindow):
'sale_device': self.device['id'],
'payment_term': self.default_payment_term['id']
}, self._context)
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'])
# FIXME ADD MORE
self._sale.update({
'total_amount': 0
@ -2572,7 +2598,9 @@ class MainWindow(FrontWindow):
elif key == Qt.Key_Backspace:
self.key_backspace_pressed()
elif key == Qt.Key_Escape:
self.close()
if not self._state in ['accept', 'cash']:
self._clear_context()
# self.close()
elif key == Qt.Key_F1:
self.create_dialog_help()
elif key == Qt.Key_F9:
@ -2623,8 +2651,10 @@ class MainWindow(FrontWindow):
self.action_comment()
elif key == Qt.Key_Question:
self.action_tax()
else:
pass
sale = self.get_current_sale()
self.field_state.setText(sale['state'])
# else:
# pass
@property
def state(self):

View File

@ -2,11 +2,11 @@
QAbstractButton {
font-family: "DejaVu Sans";
border-style: groove;
font: 20pt;
font: 16pt;
color: rgb(102, 102, 102);
background-color: rgb(242, 242, 242);
min-height: 45px;
min-width : 100px;
min-height: 40px;
min-width : 90px;
border-color: rgb(208, 208, 208);
border-width: 0.5px;
}
@ -23,38 +23,38 @@ QAbstractButton {
}
#field_default {
font : 22px;
font : 18px;
}
#field_medium_gray, #label_medium_gray {
font : 22px;
font : 18px;
color : rgb(54, 54, 54);
}
#field_medium_blue, #label_medium_blue {
font : 22px;
font : 18px;
color : rgb(0, 30, 80);
}
#field_medium_orange, #label_medium_orange {
font : 22px;
font : 18px;
color : rgb(235, 160, 15);
}
#label_qty, #spin_box_qty, #row_field_price,
#label_price, #row_field_note, #label_fraction, #row_field_qty,
#field_fraction {
font : 22px;
font : 18px;
alignment : center;
}
#row_field_description {
font : 22px;
font : 18px;
color : #242424;
}
#label_product {
font : bold 24px;
font : bold 20px;
alignment : center;
color : #242424;
}
@ -67,14 +67,14 @@ QSpinBox {
QSpinBox::up-button {
subcontrol-position: right;
height: 40px;
width: 40px;
height: 32px;
width: 32px;
}
QSpinBox::down-button {
subcontrol-position: left;
height: 40px;
width: 40px;
height: 32px;
width: 32px;
}
#field_invoice {
@ -85,14 +85,14 @@ QSpinBox::down-button {
#label_position, #label_salesman, #label_payment_term,
#label_party, #label_global_discount, #field_invoice, #label_invoice,
#label_agent, #label_date, #label_order_number, #label_default {
font : 20px;
font : 16px;
color : rgb(150, 150, 150);
min-height : 10px;
min-width : 10px;
min-width : 8px;
}
#field_amount, #field_sign {
font : bold 42px;
font : bold 38px;
color : rgb(43, 60, 77);
min-height : 40px;
max-height : 100px;
@ -114,13 +114,13 @@ QSpinBox::down-button {
#table_payment {
color : rgb(70, 70, 70);
font : 14pt;
font : 12pt;
max-height : 80px;
}
#table_sale_lines {
color : rgb(70, 70, 70);
font : 14pt;
font : 12pt;
}
#label_paid, #label_change, #label_discount, #label_total_amount,
@ -128,7 +128,7 @@ QSpinBox::down-button {
#field_total_amount, #field_change, #field_discount, #field_paid,
#field_untaxed_amount, #field_taxes_amount {
min-height : 10px;
font: bold 20pt;
font: bold 16pt;
}
#img_pixmap_pos {

View File

@ -2,7 +2,7 @@
QAbstractButton {
font-family: "DejaVu Sans";
border-style: groove;
font: 12pt;
font: 18pt;
color: rgb(102, 102, 102);
background-color: rgb(242, 242, 242);
min-height: 50px;
@ -23,110 +23,113 @@ QAbstractButton {
}
#label_default {
font : 14pt;
font : 20pt;
color : rgb(102, 102, 102);
min-height : 10px;
min-width : 10px;
min-width : 80px;
}
#field_default {
font: bold 14pt;
font: bold 20pt;
min-height : 10px;
}
#field_small_gray, #label_small_gray {
font : 16px;
font : 15px;
width: auto;
color : rgb(54, 54, 54);
}
#field_medium_gray, #label_medium_gray {
font : 24px;
font : 15px;
color : rgb(54, 54, 54);
}
#field_big_gray, #label_big_gray {
font : 32px;
font : 20px;
color : rgb(54, 54, 54);
}
#field_small_blue, #label_small_blue {
font : 16px;
font : 15px;
width: auto;
color : rgb(0, 30, 80);
}
#field_medium_blue, #label_medium_blue {
font : 24px;
font : 15px;
color : rgb(0, 30, 80);
}
#field_big_blue, #label_big_blue {
font : bold 32px;
font : bold 20px;
color : rgb(0, 30, 80);
}
#field_small_orange, #label_small_orange {
font : 16px;
font : 15px;
width: auto;
color : rgb(235, 160, 15);
}
#field_medium_orange, #label_medium_orange {
font : 24px;
font : 15px;
color : rgb(235, 160, 15);
}
#field_big_orange, #label_big_orange {
font : bold 32px;
font : bold 20px;
color : rgb(235, 160, 15);
}
QDialog {
min-height : 300px;
max-height : 400px;
min-width : 500px;
min-height : 200px;
max-height : 300px;
min-width : 100px;
}
#label_gray {
font: bold 14pt;
font: bold 15pt;
min-height : 10px;
min-width : 10px;
min-width : 20px;
color: rgb(102, 102, 102);
}
#label_blue {
font: bold 14pt;
font: bold 15pt;
color: rgb(17, 84, 102);
min-height : 10px;
min-width : 10px;
min-width : 20px;
}
#label_message {
font : 14pt;
min-height : 45px;
min-width : 10px;
font : 8pt;
min-height : 35px;
min-width : 20px;
}
#field_invoice {
font : 15pt;
min-height : 45px;
min-width : 110px;
font : 9pt;
min-height : 30px;
min-width : 80px;
}
#label_input {
font : 15pt;
min-height : 45px;
min-width : 200px;
font : 8pt;
min-height : 20px;
min-width : 180px;
}
#field_sign {
font: bold 26pt;
min-height : 70px;
max-width: 100px;
font: bold 18pt;
min-height : 20px;
max-width: 80px;
}
#field_amount {
font: 24pt;
min-height : 60px;
max-width: 310px;
font: 18pt;
min-height : 40px;
max-width: 280px;
}
#field_total_amount, #label_total_amount {
@ -135,13 +138,13 @@ QDialog {
#table_sale_lines {
color : rgb(70, 70, 70);
font : 11pt;
max-height: 380px;
font : 7pt;
max-height: 300px;
}
#label_product, #label_qty, #spin_box_qty, #row_field_price,
#label_price, #row_field_note {
font : 24px;
font : 20px;
alignment : center;
}
@ -153,12 +156,12 @@ QSpinBox {
QSpinBox::up-button {
subcontrol-position: right;
height: 38px;
width: 38px;
height: 28px;
width: 28px;
}
QSpinBox::down-button {
subcontrol-position: left;
height: 38px;
width: 38px;
height: 28px;
width: 28px;
}

View File

@ -12,7 +12,7 @@ From main directory:
3. Release translation
lrelease app/translations/i18n_es.ts
lrelease app/locale/i18n_es.ts

View File

@ -1,3 +1,3 @@
# Execute in terminal $pylupdate5 project.pro
SOURCES = app/mainwindow.py app/reporting.py app/buttonpad.py
SOURCES = app/mainwindow.py app/reporting.py app/buttonpad.py app/commons/buttons.py app/commons/dblogin.py app/commons/dialogs.py app/commons/forms.py app/commons/frontwindow.py app/commons/menu_list.py app/commons/search_window.py
TRANSLATIONS = app/locale/i18n_es.ts