fix: Se añaden impresiones para USB

This commit is contained in:
sinergia 2023-12-22 10:06:37 -05:00
parent 522a502268
commit 60f1eca39a
2 changed files with 40 additions and 24 deletions

55
sale.py
View File

@ -162,7 +162,8 @@ class Sale(metaclass=PoolMeta):
"product": line.product.name if line.type != 'title' else None,
"quantity": line.quantity if line.type != 'title' else None,
"uom": line.unit.symbol if line.type != 'title' else None,
"unit_price": str(line.amount_w_tax) if line.type != 'title' else None,
"unit_price": str(line.amount_w_tax)
if line.type != 'title' else None,
"taxes": str(round(line.taxes[0].rate * 100, 2)) + '%'
if line.type != 'title' and line.taxes else None
} for line in record.lines]
@ -171,7 +172,8 @@ class Sale(metaclass=PoolMeta):
data["untaxed_amount"] = str(record.untaxed_amount)
data["tax_amount"] = str(record.tax_amount)
data["total"] = str(record.total_amount)
data["state"] = "SUBTOTAL" if record.state == "draft" else "CUENTA FINAL"
data["state"] = \
"SUBTOTAL" if record.state == "draft" else "CUENTA FINAL"
if record.payments:
data['payments'] = [{
@ -193,13 +195,6 @@ class Sale(metaclass=PoolMeta):
data["city"] = report.invoice_address.subdivision_municipality.name
data["zone"] = report.zone.name if report.zone else ""
data["table"] = report.table.name if report.table else ""
# data["lines"] = [{
# 'type': line.type,
# "product": line.product.name if line.type != 'title' else None,
# "quantity": line.quantity if line.type != 'title' else None,
# "uom": line.unit.name if line.type != 'title' else None}
# for line in report.lines]
data["lines"] = [{
'type': line.type,
"product": line.product.name if line.type != 'title' else None,
@ -253,20 +248,26 @@ class Sale(metaclass=PoolMeta):
else:
user_name = ""
content = {"content": str(json.dumps(bill)),
"user_name": user_name}
content = {
"content": str(json.dumps(bill)),
"printer_type": "",
"ip_printer": "",
"user_name": user_name,
"idVendor": "",
"idProduct": ""}
if printer.type_ == 'network':
content["printer_type"] = "Network"
content["ip_printer"] = str(printer.ip_address),
else:
if printer.type_ == 'usb':
content["printer_type"] = "USB"
content["idVendor"] = str(printer.idVendor)
content["idProduct"] = str(printer.idProduct)
headers = {"accept": 'application/json',
'Content-Type': 'application/json'}
response = requests.post(
requests.post(
url, data=json.dumps(content), headers=headers)
@classmethod
@ -284,7 +285,6 @@ class Sale(metaclass=PoolMeta):
printer = printers[0]
url = f"http://{printer.api.ip_address}/order_kitchen"
customer_order = cls.report_customer_order(records)
if 'employee.rec_name' in context.keys():
@ -292,21 +292,28 @@ class Sale(metaclass=PoolMeta):
else:
user_name = ""
content = {"content": str(json.dumps(bill)),
"user_name": user_name}
content = {"content": str(json.dumps(customer_order)),
"printer_type": "",
"ip_printer": "",
"user_name": user_name,
"idVendor": "",
"idProduct": ""}
if printer.type_ == 'network':
content["printer_type"] = "Network"
content["ip_printer"] = str(printer.ip_address),
else:
if printer.type_ == 'usb':
content["printer_type"] = "USB"
content["idVendor"] = str(printer.idVendor)
content["idProduct"] = str(printer.idProduct)
headers = {"accept": 'application/json',
'Content-Type': 'application/json'}
cls.impreso([record])
response = requests.post(url, data=json.dumps(content),
headers=headers)
requests.post(url, data=json.dumps(content),
headers=headers)
@classmethod
@ModelView.button
@ -333,13 +340,19 @@ class Sale(metaclass=PoolMeta):
user_name = ""
content = {
"content": str(json.dumps(bill)),
"user_name": user_name}
"content": str(json.dumps(customer_order)),
"printer_type": "",
"ip_printer": "",
"user_name": user_name,
"idVendor": "",
"idProduct": ""}
if printer.type_ == 'network':
content["printer_type"] = "Network"
content["ip_printer"] = str(printer.ip_address),
else:
if printer.type_ == 'usb':
content["printer_type"] = "USB"
content["idVendor"] = str(printer.idVendor)
content["idProduct"] = str(printer.idProduct)
@ -349,6 +362,8 @@ class Sale(metaclass=PoolMeta):
response = requests.post(url, data=json.dumps(content),
headers=headers)
raise Exception(response)
class Line(metaclass=PoolMeta):
"Sale Line Fast Food"

View File

@ -10,6 +10,7 @@ depends:
production
account_invoice
sale_shop
sale_pos_table
xml:
product.xml
sale.xml