Add button Impreso

This commit is contained in:
cosmos 2023-08-02 15:45:55 -05:00
parent a4a4481312
commit 3b058e0e4a
4 changed files with 28 additions and 13 deletions

31
sale.py
View File

@ -20,6 +20,7 @@ class Sale(metaclass=PoolMeta):
'kitchen': {},
'bar': {},
'print_bill': {},
'impreso': {},
})
@ -120,16 +121,10 @@ class Sale(metaclass=PoolMeta):
"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,
# "quantity": line.quantity if line.type != 'title' else None,
# "uom": line.unit.name if line.type != 'title' else None} for line in report.lines if line.impreso == False]
#for line in data["lines"]:
# line.impreso = True
#record.save()
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 if line.impreso == False]
return data
@ -144,6 +139,15 @@ class Sale(metaclass=PoolMeta):
record.lines += (saleLine(type="title",
description="Pizza Combinada"),)
record.save()
@classmethod
@ModelView.button
def impreso(cls, records):
record = records[0]
for line in record.lines:
line.impreso = True
line.save()
record.save()
@classmethod
@ModelView.button
@ -198,6 +202,7 @@ class Sale(metaclass=PoolMeta):
shop = context['shop']
Printer = pool.get('sale.printer')
printers = Printer.search([('zone', '=', 'bar'), ('shop', '=', shop)])
record = records[0]
if not printers:
return
@ -206,6 +211,10 @@ class Sale(metaclass=PoolMeta):
url = f"http://{printer.api.ip_address}/order_bar"
customer_order = cls.report_customer_order(records)
cls.impreso([record])
#cls.impreso(records)
content = {"content": str(json.dumps(customer_order)), "ip_printer": str(printer.ip_address)}
headers = {"accept": 'application/json', 'Content-Type': 'application/json'}
@ -218,7 +227,7 @@ class Line(metaclass=PoolMeta):
__name__ = 'sale.line'
pizza = fields.Integer("Pizza")
#impreso = fields.Boolean("Impreso")
impreso = fields.Boolean("Impreso")
@fields.depends('product', 'unit', 'sale',
'_parent_sale.party', '_parent_sale.invoice_party',

View File

@ -37,6 +37,11 @@
<field name="string">Bill</field>
<field name="model" search="[('model', '=', 'sale.sale')]"/>
</record>
<record model="ir.model.button" id="sale_impreso_button">
<field name="name">impreso</field>
<field name="string">Impreso</field>
<field name="model" search="[('model', '=', 'sale.sale')]"/>
</record>
<record model="ir.action.report" id="report_customer_order">
<field name="name">Customer Order</field>
<field name="model">sale.sale</field>

View File

@ -10,5 +10,7 @@ this repository contains the full copyright notices and license terms. -->
<button name="kitchen"/>
<button name="bar"/>
<button name="print_bill"/>
<newline/>
<button name="impreso"/>
</xpath>
</data>

View File

@ -5,8 +5,7 @@
<xpath expr="//field[@name='product']" position="after">
<label name="pizza"/>
<field name="pizza"/>
<!--
<label name="impreso"/>
<field name="impreso"/>-->
<field name="impreso"/>
</xpath>
</data>