add option for restaurant print quotation
This commit is contained in:
parent
da288790a8
commit
45725ea3df
|
@ -79,10 +79,9 @@ class TableEdit(QAbstractTableModel):
|
|||
return None
|
||||
try:
|
||||
return next(islice(self._fields, section, None))['label']
|
||||
except:
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
return None
|
||||
# if orientation == Qt.Horizontal:
|
||||
# return None
|
||||
|
||||
def add_record(self, rec):
|
||||
length = len(self._data)
|
||||
|
@ -135,20 +134,24 @@ class TableModel(QAbstractTableModel):
|
|||
return len(self._fields) if self._fields else 0
|
||||
|
||||
def get_data(self, index):
|
||||
raw_value = self._data[index.row()]
|
||||
try:
|
||||
raw_value = self._data[index.row()]
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
raw_value = {}
|
||||
return raw_value
|
||||
|
||||
def get_value(self, data, field):
|
||||
value = ''
|
||||
list_ = field.split('.')
|
||||
if len(list_) > 1:
|
||||
for l in list_[:-1]:
|
||||
l = l + '.'
|
||||
data = data[l]
|
||||
for ln in list_[:-1]:
|
||||
ln = ln + '.'
|
||||
data = data[ln]
|
||||
try:
|
||||
value = data[list_[-1]]
|
||||
except:
|
||||
print(data, field)
|
||||
except Exception as e:
|
||||
print(data, field, str(e))
|
||||
return value
|
||||
|
||||
def data(self, index, role, field_name='name'):
|
||||
|
|
|
@ -35,7 +35,7 @@ class TableView(QTableView):
|
|||
header.setStretchLastSection(True)
|
||||
if col_sizes:
|
||||
for i, size in enumerate(col_sizes):
|
||||
if type(size) == int:
|
||||
if isinstance(size, int):
|
||||
header.resizeSection(i, size)
|
||||
else:
|
||||
header.setSectionResizeMode(i, STRETCH)
|
||||
|
@ -92,20 +92,24 @@ class TableView(QTableView):
|
|||
return
|
||||
if index.row() >= 0:
|
||||
if self.hasFocus() or ignore_focus:
|
||||
item = self.model.get_data(index)
|
||||
id_ = self.model.removeId(index.row(), index)
|
||||
self.model.deleteRecords([id_])
|
||||
self.model.removeId(index.row(), index)
|
||||
# This options is unnecessary deleteRecords function not implemented
|
||||
# id_ = self.model.removeId(index.row(), index)
|
||||
# self.model.deleteRecords([id_])
|
||||
self.model.layoutChanged.emit()
|
||||
return item
|
||||
|
||||
def delete_selected(self):
|
||||
for idx in self.selected_rows:
|
||||
# order rows by index reverse for delete correct records
|
||||
rows_ = {r.row(): r for r in self.selected_rows}
|
||||
rows_ = dict(sorted(rows_.items(), key=lambda x: x[0], reverse=True))
|
||||
for idx in rows_.values():
|
||||
self.removeElement(idx, True)
|
||||
|
||||
def delete_item(self, ignore_focus=False):
|
||||
item_removed = {}
|
||||
selected_idx = self.currentIndex()
|
||||
item_removed = self.removeElement(selected_idx, ignore_focus)
|
||||
item_removed = self.model.get_data(selected_idx)
|
||||
self.removeElement(selected_idx, ignore_focus)
|
||||
return item_removed
|
||||
|
||||
def moved_selection(self, key):
|
||||
|
|
|
@ -704,7 +704,7 @@ class DialogPrintInvoice(QuickDialog):
|
|||
'values': [
|
||||
('invoice', 'FACTURA'),
|
||||
('order', 'ORDEN'),
|
||||
# ('delivery', ('DELIVERY'))
|
||||
('quotation', 'COTIZACION')
|
||||
],
|
||||
}),
|
||||
('printer_ask', {
|
||||
|
|
|
@ -1555,7 +1555,7 @@ class AppWindow(FrontWindow):
|
|||
sale_id = None
|
||||
sale = self._sale
|
||||
if number:
|
||||
if type_doc in ['order', 'delivery']:
|
||||
if type_doc in ['order', 'delivery', 'quotation']:
|
||||
if number == self._sale.get('number'):
|
||||
sale_id = self._sale['id']
|
||||
else:
|
||||
|
|
|
@ -37,10 +37,12 @@ _DIGITS_CODE_RECEIPT = 4
|
|||
_FONT_A = 'a' # Normal Font
|
||||
_FONT_B = 'b' # Condensed Font
|
||||
|
||||
if os.name == 'posix':
|
||||
OS_NAME = os.name
|
||||
|
||||
if OS_NAME == 'posix':
|
||||
homex = 'HOME'
|
||||
dirconfig = '.tryton/temp'
|
||||
elif os.name == 'nt':
|
||||
elif OS_NAME == 'nt':
|
||||
homex = 'USERPROFILE'
|
||||
dirconfig = 'AppData/Local/tryton/temp'
|
||||
|
||||
|
@ -134,10 +136,10 @@ class Receipt(object):
|
|||
|
||||
def test_printer(self):
|
||||
if self._interface == 'usb':
|
||||
if os.name == 'posix':
|
||||
if OS_NAME == 'posix':
|
||||
self._printer = printer.File(
|
||||
self._device, profile=self._profile)
|
||||
elif os.name == 'nt':
|
||||
elif OS_NAME == 'nt':
|
||||
self._printer = printer.Win32Raw(self._device)
|
||||
self._printer.open()
|
||||
elif self._interface == 'network':
|
||||
|
@ -179,10 +181,11 @@ class Receipt(object):
|
|||
def set_printer(self):
|
||||
try:
|
||||
if self._interface == 'usb':
|
||||
if os.name == 'posix':
|
||||
if OS_NAME == 'posix':
|
||||
print()
|
||||
self._printer = printer.File(
|
||||
self._device, profile=self._profile)
|
||||
elif os.name == 'nt':
|
||||
elif OS_NAME == 'nt':
|
||||
self._printer = printer.Win32Raw(self._device)
|
||||
self._printer.open()
|
||||
elif self._interface == 'network':
|
||||
|
@ -208,16 +211,20 @@ class Receipt(object):
|
|||
except:
|
||||
traceback.print_exc()
|
||||
self.logger.info("Warning: Printer error or device not found!")
|
||||
|
||||
def validate_printer(self, _interface, ):
|
||||
return
|
||||
|
||||
|
||||
def print_sale(self, sale, type_doc=None, open_box=False):
|
||||
try:
|
||||
# if call this function we can ommit line 216 to 238
|
||||
# self.set_printer()
|
||||
if self._interface == 'usb':
|
||||
if os.name == 'posix':
|
||||
if OS_NAME == 'posix':
|
||||
self._printer = printer.File(
|
||||
self._device, profile=self._profile)
|
||||
elif os.name == 'nt':
|
||||
elif OS_NAME == 'nt':
|
||||
self._printer = printer.Win32Raw(self._device)
|
||||
self._printer.open()
|
||||
elif self._interface == 'network':
|
||||
|
@ -241,14 +248,15 @@ class Receipt(object):
|
|||
return
|
||||
self.logger.info("Info: Printer is OK!")
|
||||
try:
|
||||
if type_doc == 'invoice' or self._environment == 'retail':
|
||||
if type_doc in ('invoice', 'quotation') or self._environment == 'retail':
|
||||
self._print_sale(sale, type_doc, open_box)
|
||||
else:
|
||||
self._print_sale_verification(sale)
|
||||
except:
|
||||
pass
|
||||
self._printer.close()
|
||||
except:
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
self.logger.info("Warning: Printer error or device not found!")
|
||||
|
||||
def _print_sale(self, sale, type_doc=None, open_box=False):
|
||||
|
@ -820,11 +828,11 @@ class Receipt(object):
|
|||
host = order['host']
|
||||
|
||||
if order['interface'] == 'usb':
|
||||
if os.name == 'posix':
|
||||
if OS_NAME == 'posix':
|
||||
self._printer = printer.File(host)
|
||||
self._printer.close()
|
||||
self._printer.open()
|
||||
elif os.name == 'nt':
|
||||
elif OS_NAME == 'nt':
|
||||
self._printer = printer.Win32Raw(host)
|
||||
self._printer.open()
|
||||
elif order['interface'] == 'network':
|
||||
|
|
Loading…
Reference in New Issue