minor fix

This commit is contained in:
wilson gomez 2021-11-12 09:02:39 -05:00
parent 34d0b3dcd3
commit f3c6d2348f
2 changed files with 36 additions and 22 deletions

View File

@ -1752,7 +1752,7 @@ class AppWindow(FrontWindow):
dom.append(['payment_term', '=', self.default_payment_term['id']])
else:
dom.append(['payment_term', '!=', self.default_payment_term['id']])
dom.append(['payment_method', '!=', 'all_paid'])
# dom.append(['payment_method', '!=', 'all_paid'])
fields = self.dialog_search_sales.fields_names
sales = self.Sale.find(dom, fields=fields, order=[('id', 'DESC')])

View File

@ -132,7 +132,8 @@ class Receipt(object):
def test_printer(self):
if self._interface == 'usb':
if os.name == 'posix':
self._printer = printer.File(self._device, profile=self._profile)
self._printer = printer.File(
self._device, profile=self._profile)
elif os.name == 'nt':
self._printer = printer.Win32Raw(self._device)
self._printer.open()
@ -171,7 +172,8 @@ class Receipt(object):
try:
if self._interface == 'usb':
if os.name == 'posix':
self._printer = printer.File(self._device, profile=self._profile)
self._printer = printer.File(
self._device, profile=self._profile)
elif os.name == 'nt':
self._printer = printer.Win32Raw(self._device)
self._printer.open()
@ -195,7 +197,8 @@ class Receipt(object):
try:
if self._interface == 'usb':
if os.name == 'posix':
self._printer = printer.File(self._device, profile=self._profile)
self._printer = printer.File(
self._device, profile=self._profile)
elif os.name == 'nt':
self._printer = printer.Win32Raw(self._device)
self._printer.open()
@ -234,7 +237,7 @@ class Receipt(object):
if self._interface == 'cups':
self._file.close()
self.conn.printFile(self._printer_name, TEMP_INVOICE_FILE,
'POS Invoice', {})
'POS Invoice', {})
else:
self._printer.close()
@ -448,7 +451,8 @@ class Receipt(object):
self.print_horinzontal_line()
self.print_split(' Articulo ', 'Subtotal ')
self.print_horinzontal_line()
len_row = self._row_characters - (_DIGITS_CODE_RECEIPT + 1) - (_DIGITS + 1)
len_row = self._row_characters - \
(_DIGITS_CODE_RECEIPT + 1) - (_DIGITS + 1)
for line in sale['lines']:
if line['taxes'] and _PRINT_TAX_ID:
tax_id = ' ' + str(line['taxes'][0].id)
@ -478,7 +482,8 @@ class Receipt(object):
self._printer.text(first_line + '\n')
unit_price_w_tax = str(round(line['unit_price_w_tax'], 2))
second_line = ' %s x %s' % (line['quantity'], unit_price_w_tax)
second_line = ' %s x %s' % (
line['quantity'], unit_price_w_tax)
second_line = second_line.encode('utf-8')
self.print_split(second_line, line_total)
if line['discount'] and Decimal(line['discount']) and self._show_discount:
@ -574,7 +579,8 @@ class Receipt(object):
self._printer.set(font=_FONT_B)
kind_string = sale.get('kind_string', None)
if type_doc != 'invoice' and kind_string:
self._printer.set(custom_size=True, width=2, height=2, align='center')
self._printer.set(custom_size=True, width=2,
height=2, align='center')
kind = f'- - - {kind_string} - - -'
self._printer.text(kind)
self.print_enter()
@ -584,7 +590,8 @@ class Receipt(object):
if type_doc == 'invoice':
if sale['number']:
if sale['total_amount'] >= 0:
self._printer.text('FACTURA DE VENTA No. ' + sale['number'])
self._printer.text(
'FACTURA DE VENTA No. ' + sale['number'])
else:
self._printer.text('NOTA CREDITO No. ' + sale['number'])
elif type_doc in ['order', 'delivery']:
@ -634,9 +641,12 @@ class Receipt(object):
self.print_enter()
taxes = sale['taxes']
for tax in taxes:
self.print_col(str(taxes[tax]['name']) + ' ', self.taxes_col_width1)
self.print_col(str(int(taxes[tax]['base'])), self.taxes_col_width2)
self.print_col(str(int(taxes[tax]['tax'])), self.taxes_col_width3)
self.print_col(str(taxes[tax]['name'])
+ ' ', self.taxes_col_width1)
self.print_col(
str(int(taxes[tax]['base'])), self.taxes_col_width2)
self.print_col(
str(int(taxes[tax]['tax'])), self.taxes_col_width3)
self.print_enter()
self.print_enter()
@ -650,7 +660,8 @@ class Receipt(object):
payments = sale['payments']
for p in payments:
self.print_col(str(p['name']) + ' ', self.payments_col_width1)
self.print_col(str(p['voucher']) + ' ', self.payments_col_width2)
self.print_col(str(p['voucher']) + ' ',
self.payments_col_width2)
self.print_col(str(int(p['amount'])), self.payments_col_width3)
self.print_enter()
@ -771,7 +782,8 @@ class Receipt(object):
elif order['interface'] == 'cups':
pass
if not self._printer:
self.logger.info("Warning: Interface not found for printer!")
self.logger.info(
"Warning: Interface not found for printer!")
res.append(None)
continue
@ -830,7 +842,8 @@ class Receipt(object):
table_assigned = order.get('table_assigned', None)
if table_assigned:
self.print_enter()
self._printer.set(custom_size=True, width=2, height=2, align='center')
self._printer.set(custom_size=True, width=2,
height=2, align='center')
self._printer.text('MESA: %s' % table_assigned)
self.print_enter()
self._printer.set(align='left')
@ -868,7 +881,8 @@ class Receipt(object):
self._printer.set(align='center')
if self.order_kind == 'command':
self._printer.set(custom_size=True, width=2, height=2, align='center')
self._printer.set(custom_size=True, width=2,
height=2, align='center')
if reversion:
self._printer.text('>> R E V E R S I O N <<')
self.print_enter()
@ -886,11 +900,11 @@ class Receipt(object):
qty = ' ' + str(int(Decimal(line['quantity'])))
self.print_col(qty, self.order_col_1)
self.print_col(line['name'], col_width_name)
if line['note']:
self.print_enter()
for msg_note in line['note'].split('\n'):
self._printer.text(f' NOTA -> {msg_note}')
self.print_enter()
# if line['note']:
# self.print_enter()
# for msg_note in line['note'].split('\n'):
# self._printer.text(f' NOTA -> {msg_note}')
# self.print_enter()
self.print_enter()
self.print_enter()
@ -968,7 +982,7 @@ if __name__ == '__main__':
# device = 'network', '192.168.0.33'
# Unix-like Usb example
device = ('usb',' /dev/usb/lp1')
device = ('usb', ' /dev/usb/lp1')
# Windows Usb example for printer name SATPOS
# device = 'usb', 'SATPOS'