Compare commits

...

2 Commits

3 changed files with 42 additions and 3 deletions

28
sale.py
View File

@ -1,7 +1,10 @@
from trytond.pool import Pool, PoolMeta from trytond.pool import Pool, PoolMeta
from trytond.model import ModelView, fields from trytond.model import ModelView, fields
from trytond.transaction import Transaction
from trytond.exceptions import UserError from trytond.exceptions import UserError
import requests
import json
class Sale(metaclass=PoolMeta): class Sale(metaclass=PoolMeta):
"Sale Fast Food" "Sale Fast Food"
@ -14,6 +17,8 @@ class Sale(metaclass=PoolMeta):
super(Sale, cls).__setup__() super(Sale, cls).__setup__()
cls._buttons.update({ cls._buttons.update({
'add_pizza': {}, 'add_pizza': {},
'kitchen': {},
'bar': {}
}) })
@classmethod @classmethod
@ -26,13 +31,30 @@ class Sale(metaclass=PoolMeta):
pool = Pool() pool = Pool()
saleLine = pool.get('sale.line') saleLine = pool.get('sale.line')
for record in records: for record in records:
#raise UserError(str(record.lines))
record.pizza_number +=1 record.pizza_number +=1
record.lines += (saleLine(type="title", record.lines += (saleLine(type="title",
description="Pizza Combinada"),) description="Pizza Combinada"),)
record.save() record.save()
@classmethod
@ModelView.button
#@ModelView.button_action('sale_fast_food.report_customer_order')
def kitchen(cls, records):
pool = Pool()
Report = pool.get('sale.customer_order', type='report')
context = Transaction().context
#customer_order = Report.execute(records, context)
data = {"content": "Esto es una pruebas"}
url = "http://localhost:5000/print_ticket"
response = requests.post(url, json=json.dumps(data), headers={'Content-Type': 'application/json'})
#response = requests.post(url, json={"content": customer_order[1]})
raise UserError(str(response))
if response.status_code == 200:
message = response.Text
raise UserError(str(message))
class Line(metaclass=PoolMeta): class Line(metaclass=PoolMeta):
"Sale Line Fast Food" "Sale Line Fast Food"
__name__ = 'sale.line' __name__ = 'sale.line'

View File

@ -22,4 +22,20 @@
<field name="string">Add Pizza</field> <field name="string">Add Pizza</field>
<field name="model" search="[('model', '=', 'sale.sale')]"/> <field name="model" search="[('model', '=', 'sale.sale')]"/>
</record> </record>
<record model="ir.model.button" id="sale_customer_order_button">
<field name="name">kitchen</field>
<field name="string">Kitchen</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>
<field name="report_name">sale.customer_order</field>
<field name="report">sale_fast_food/report/customer_order.fodt</field>
</record>
<record model="ir.action.keyword" id="report_customer_order_keyword">
<field name="keyword">form_print</field>
<field name="model">sale.sale,-1</field>
<field name="action" ref="report_customer_order"/>
</record>
</tryton> </tryton>

View File

@ -7,5 +7,6 @@
<label name="pizza_number"/> <label name="pizza_number"/>
<field name="pizza_number"/> <field name="pizza_number"/>
<button name="add_pizza"/> <button name="add_pizza"/>
<button name="kitchen"/>
</xpath> </xpath>
</data> </data>