add information for print bill ticket
This commit is contained in:
parent
1c65c9da81
commit
7b244fa0da
19
sale.py
19
sale.py
@ -36,8 +36,12 @@ class Sale(metaclass=PoolMeta):
|
|||||||
ctx = Transaction().context
|
ctx = Transaction().context
|
||||||
report = records[0]
|
report = records[0]
|
||||||
User = pool.get('res.user')
|
User = pool.get('res.user')
|
||||||
|
Shop = pool.get('sale.shop')
|
||||||
data = {}
|
data = {}
|
||||||
user = User(Transaction().user)
|
user = User(Transaction().user)
|
||||||
|
shop = Shop.search([('id', '=', ctx["shop"])])[0]
|
||||||
|
data["shop_name"] = shop.name
|
||||||
|
data["shop_address"] = shop.address.street
|
||||||
data["user"] = user.name
|
data["user"] = user.name
|
||||||
data["party"] = report.party.name
|
data["party"] = report.party.name
|
||||||
data["tax_identifier_type"] = report.party.tax_identifier.type_string
|
data["tax_identifier_type"] = report.party.tax_identifier.type_string
|
||||||
@ -49,11 +53,16 @@ class Sale(metaclass=PoolMeta):
|
|||||||
data["lines"] = [{'type': line.type,
|
data["lines"] = [{'type': line.type,
|
||||||
"product": line.product.name if line.type != 'title' else None,
|
"product": line.product.name if line.type != 'title' else None,
|
||||||
"quantity": line.quantity 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,
|
"uom": line.unit.symbol if line.type != 'title' else None,
|
||||||
"unit_price": line.unit_price if line.type != 'title' else None,
|
"unit_price": str(line.unit_price) if line.type != 'title' else None,
|
||||||
"taxes": line.taxes[0] if line.type != 'title' and line.taxes else None
|
"taxes": str(round(line.taxes[0].rate * 100, 2))+'%' if line.type != 'title' and line.taxes else None
|
||||||
} for line in report.lines]
|
} for line in report.lines]
|
||||||
|
|
||||||
|
data["untaxed_amount"] = str(report.untaxed_amount)
|
||||||
|
data["tax_amount"] = str(report.tax_amount)
|
||||||
|
data["total"] = str(report.total_amount)
|
||||||
|
return data
|
||||||
|
|
||||||
def report_customer_order(records):
|
def report_customer_order(records):
|
||||||
if not records:
|
if not records:
|
||||||
return
|
return
|
||||||
@ -106,8 +115,8 @@ class Sale(metaclass=PoolMeta):
|
|||||||
|
|
||||||
url = f"http://{printer.api.ip_address}/print_bill"
|
url = f"http://{printer.api.ip_address}/print_bill"
|
||||||
|
|
||||||
customer_order = cls.report_customer_order(records)
|
bill = cls.report_bill(records)
|
||||||
content = {"content": str(json.dumps(customer_order)), "ip_printer": str(printer.ip_address)}
|
content = {"content": str(json.dumps(bill)), "ip_printer": str(printer.ip_address)}
|
||||||
headers = {"accept": 'application/json', 'Content-Type': 'application/json'}
|
headers = {"accept": 'application/json', 'Content-Type': 'application/json'}
|
||||||
|
|
||||||
response = requests.post(url, data=json.dumps(content), headers=headers)
|
response = requests.post(url, data=json.dumps(content), headers=headers)
|
||||||
|
Loading…
Reference in New Issue
Block a user