Add button Impreso
This commit is contained in:
parent
a4a4481312
commit
3b058e0e4a
31
sale.py
31
sale.py
@ -20,6 +20,7 @@ class Sale(metaclass=PoolMeta):
|
|||||||
'kitchen': {},
|
'kitchen': {},
|
||||||
'bar': {},
|
'bar': {},
|
||||||
'print_bill': {},
|
'print_bill': {},
|
||||||
|
'impreso': {},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -120,16 +121,10 @@ class Sale(metaclass=PoolMeta):
|
|||||||
"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} for line in report.lines]
|
"uom": line.unit.name if line.type != 'title' else None} for line in report.lines]
|
||||||
|
|
||||||
#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} for line in report.lines if line.impreso == False]
|
"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()
|
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@ -145,6 +140,15 @@ class Sale(metaclass=PoolMeta):
|
|||||||
description="Pizza Combinada"),)
|
description="Pizza Combinada"),)
|
||||||
record.save()
|
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
|
@classmethod
|
||||||
@ModelView.button
|
@ModelView.button
|
||||||
def print_bill(cls, records):
|
def print_bill(cls, records):
|
||||||
@ -198,6 +202,7 @@ class Sale(metaclass=PoolMeta):
|
|||||||
shop = context['shop']
|
shop = context['shop']
|
||||||
Printer = pool.get('sale.printer')
|
Printer = pool.get('sale.printer')
|
||||||
printers = Printer.search([('zone', '=', 'bar'), ('shop', '=', shop)])
|
printers = Printer.search([('zone', '=', 'bar'), ('shop', '=', shop)])
|
||||||
|
record = records[0]
|
||||||
|
|
||||||
if not printers:
|
if not printers:
|
||||||
return
|
return
|
||||||
@ -206,6 +211,10 @@ class Sale(metaclass=PoolMeta):
|
|||||||
url = f"http://{printer.api.ip_address}/order_bar"
|
url = f"http://{printer.api.ip_address}/order_bar"
|
||||||
|
|
||||||
customer_order = cls.report_customer_order(records)
|
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)}
|
content = {"content": str(json.dumps(customer_order)), "ip_printer": str(printer.ip_address)}
|
||||||
headers = {"accept": 'application/json', 'Content-Type': 'application/json'}
|
headers = {"accept": 'application/json', 'Content-Type': 'application/json'}
|
||||||
|
|
||||||
@ -218,7 +227,7 @@ class Line(metaclass=PoolMeta):
|
|||||||
__name__ = 'sale.line'
|
__name__ = 'sale.line'
|
||||||
|
|
||||||
pizza = fields.Integer("Pizza")
|
pizza = fields.Integer("Pizza")
|
||||||
#impreso = fields.Boolean("Impreso")
|
impreso = fields.Boolean("Impreso")
|
||||||
|
|
||||||
@fields.depends('product', 'unit', 'sale',
|
@fields.depends('product', 'unit', 'sale',
|
||||||
'_parent_sale.party', '_parent_sale.invoice_party',
|
'_parent_sale.party', '_parent_sale.invoice_party',
|
||||||
|
5
sale.xml
5
sale.xml
@ -37,6 +37,11 @@
|
|||||||
<field name="string">Bill</field>
|
<field name="string">Bill</field>
|
||||||
<field name="model" search="[('model', '=', 'sale.sale')]"/>
|
<field name="model" search="[('model', '=', 'sale.sale')]"/>
|
||||||
</record>
|
</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">
|
<record model="ir.action.report" id="report_customer_order">
|
||||||
<field name="name">Customer Order</field>
|
<field name="name">Customer Order</field>
|
||||||
<field name="model">sale.sale</field>
|
<field name="model">sale.sale</field>
|
||||||
|
@ -10,5 +10,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
<button name="kitchen"/>
|
<button name="kitchen"/>
|
||||||
<button name="bar"/>
|
<button name="bar"/>
|
||||||
<button name="print_bill"/>
|
<button name="print_bill"/>
|
||||||
|
<newline/>
|
||||||
|
<button name="impreso"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</data>
|
</data>
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
<xpath expr="//field[@name='product']" position="after">
|
<xpath expr="//field[@name='product']" position="after">
|
||||||
<label name="pizza"/>
|
<label name="pizza"/>
|
||||||
<field name="pizza"/>
|
<field name="pizza"/>
|
||||||
<!--
|
|
||||||
<label name="impreso"/>
|
<label name="impreso"/>
|
||||||
<field name="impreso"/>-->
|
<field name="impreso"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</data>
|
</data>
|
||||||
|
Loading…
Reference in New Issue
Block a user