Compare commits
11 Commits
main
...
55cefcb8ca
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55cefcb8ca | ||
| b38ac4cb3e | |||
| 2494b0b906 | |||
| 5054666e40 | |||
| d9df054288 | |||
| a723842c36 | |||
| 24da82aa41 | |||
| 0bfc36b7c2 | |||
| 8049d555f2 | |||
| e170c152ab | |||
| 975b64f44f |
@@ -1,5 +1,5 @@
|
|||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from . import product, sale
|
from . import product, sale, production, invoice
|
||||||
|
|
||||||
__all__ = ['register']
|
__all__ = ['register']
|
||||||
|
|
||||||
@@ -7,8 +7,10 @@ __all__ = ['register']
|
|||||||
def register():
|
def register():
|
||||||
Pool.register(
|
Pool.register(
|
||||||
product.Product,
|
product.Product,
|
||||||
|
invoice.InvoiceLine,
|
||||||
sale.Sale,
|
sale.Sale,
|
||||||
sale.Line,
|
sale.Line,
|
||||||
|
production.Production,
|
||||||
module='sale_fast_food', type_='model')
|
module='sale_fast_food', type_='model')
|
||||||
Pool.register(
|
Pool.register(
|
||||||
module='sale_fast_food', type_='wizard')
|
module='sale_fast_food', type_='wizard')
|
||||||
|
|||||||
16
invoice.py
Normal file
16
invoice.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from trytond.pool import Pool, PoolMeta
|
||||||
|
from trytond.model import ModelView, fields
|
||||||
|
from trytond.exceptions import UserError
|
||||||
|
from trytond.pyson import Eval
|
||||||
|
|
||||||
|
|
||||||
|
class InvoiceLine(metaclass=PoolMeta):
|
||||||
|
__name__ = 'account.invoice.line'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def __setup__(cls):
|
||||||
|
super(InvoiceLine, cls).__setup__()
|
||||||
|
|
||||||
|
cls.product.states['required'] = (Eval('type') == 'line')
|
||||||
|
cls.unit_price.domain = []
|
||||||
|
|
||||||
@@ -6,6 +6,10 @@ msgctxt "field:product.template,pizza:"
|
|||||||
msgid "Pizza"
|
msgid "Pizza"
|
||||||
msgstr "Pizza"
|
msgstr "Pizza"
|
||||||
|
|
||||||
msgctxt "field:product.template,pizza:"
|
msgctxt "field:product.template,pizza_topping:"
|
||||||
msgid "Topping Pizza"
|
msgid "Topping Pizza"
|
||||||
msgstr "Adiciónes"
|
msgstr "Adiciónes"
|
||||||
|
|
||||||
|
msgctxt "field:product.template,boms:"
|
||||||
|
msgid "Boms"
|
||||||
|
msgstr "Lista de Materiales"
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
from trytond.pool import Pool, PoolMeta
|
from trytond.pool import Pool, PoolMeta
|
||||||
from trytond.model import fields
|
from trytond.model import fields
|
||||||
|
from trytond.pyson import Eval, Bool
|
||||||
|
|
||||||
|
|
||||||
class Product(metaclass=PoolMeta):
|
class Product(metaclass=PoolMeta):
|
||||||
@@ -7,4 +8,6 @@ class Product(metaclass=PoolMeta):
|
|||||||
__name__ = 'product.template'
|
__name__ = 'product.template'
|
||||||
|
|
||||||
pizza = fields.Boolean("Pizza")
|
pizza = fields.Boolean("Pizza")
|
||||||
Pizza_topping = fields.Boolean("Topping Pizza")
|
pizza_topping = fields.Boolean("Topping Pizza")
|
||||||
|
boms = fields.Many2One('production.bom', "Boms",
|
||||||
|
states={'required': Eval('producible', True)})
|
||||||
|
|||||||
62
production.py
Normal file
62
production.py
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
|
# this repository contains the full copyright notices and license terms.
|
||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
|
from trytond.pool import Pool, PoolMeta
|
||||||
|
from trytond.model import fields
|
||||||
|
from trytond.modules.product import price_digits, round_price
|
||||||
|
|
||||||
|
from trytond.exceptions import UserError
|
||||||
|
|
||||||
|
|
||||||
|
BOM_CHANGES = ['bom', 'product', 'quantity', 'uom', 'warehouse', 'location',
|
||||||
|
'company', 'inputs', 'outputs']
|
||||||
|
|
||||||
|
class Production(metaclass=PoolMeta):
|
||||||
|
"Production"
|
||||||
|
__name__ = 'production'
|
||||||
|
|
||||||
|
|
||||||
|
@fields.depends(*BOM_CHANGES)
|
||||||
|
def explode_bom(self):
|
||||||
|
pool = Pool()
|
||||||
|
Uom = pool.get('product.uom')
|
||||||
|
if not (self.bom and self.product and self.uom):
|
||||||
|
return
|
||||||
|
|
||||||
|
factor = self.bom.compute_factor(self.product, self.quantity or 0,
|
||||||
|
self.uom)
|
||||||
|
|
||||||
|
inputs = []
|
||||||
|
for input_ in self.bom.inputs:
|
||||||
|
if input_.product.producible:
|
||||||
|
for input_ in input_.product.template.boms.inputs:
|
||||||
|
quantity = input_.compute_quantity(factor)
|
||||||
|
move = self._explode_move_values(
|
||||||
|
self.picking_location, self.location, self.company,
|
||||||
|
input_, quantity)
|
||||||
|
if move:
|
||||||
|
inputs.append(move)
|
||||||
|
quantity = Uom.compute_qty(input_.uom, quantity,
|
||||||
|
input_.product.default_uom, round=False)
|
||||||
|
else:
|
||||||
|
quantity = input_.compute_quantity(factor)
|
||||||
|
move = self._explode_move_values(
|
||||||
|
self.picking_location, self.location, self.company,
|
||||||
|
input_, quantity)
|
||||||
|
if move:
|
||||||
|
inputs.append(move)
|
||||||
|
quantity = Uom.compute_qty(input_.uom, quantity,
|
||||||
|
input_.product.default_uom, round=False)
|
||||||
|
self.inputs = inputs
|
||||||
|
|
||||||
|
outputs = []
|
||||||
|
for output in self.bom.outputs:
|
||||||
|
quantity = output.compute_quantity(factor)
|
||||||
|
move = self._explode_move_values(
|
||||||
|
self.location, self.output_location, self.company, output,
|
||||||
|
quantity)
|
||||||
|
if move:
|
||||||
|
move.unit_price = Decimal(0)
|
||||||
|
outputs.append(move)
|
||||||
|
self.outputs = outputs
|
||||||
35
sale.py
35
sale.py
@@ -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
|
||||||
@@ -23,11 +28,32 @@ class Sale(metaclass=PoolMeta):
|
|||||||
@classmethod
|
@classmethod
|
||||||
@ModelView.button
|
@ModelView.button
|
||||||
def add_pizza(cls, records):
|
def add_pizza(cls, records):
|
||||||
|
pool = Pool()
|
||||||
|
saleLine = pool.get('sale.line')
|
||||||
for record in records:
|
for record in records:
|
||||||
record.pizza_number +=1
|
record.pizza_number +=1
|
||||||
|
record.lines += (saleLine(type="title",
|
||||||
|
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"}
|
||||||
|
headers = {"accept": 'application/json', 'Content-Type': 'application/json'}
|
||||||
|
url = "http://localhost:5000/print_ticket"
|
||||||
|
response = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
|
||||||
|
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'
|
||||||
@@ -44,3 +70,10 @@ class Line(metaclass=PoolMeta):
|
|||||||
super(Line, self).on_change_product()
|
super(Line, self).on_change_product()
|
||||||
if self.product.pizza:
|
if self.product.pizza:
|
||||||
self.pizza = self.sale.pizza_number
|
self.pizza = self.sale.pizza_number
|
||||||
|
|
||||||
|
def get_production(self):
|
||||||
|
"Return production for the sale line"
|
||||||
|
Production = super(Line, self).get_production()
|
||||||
|
#Production.bom = self.product.template.boms.id
|
||||||
|
|
||||||
|
return Production
|
||||||
|
|||||||
16
sale.xml
16
sale.xml
@@ -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>
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ depends:
|
|||||||
ir
|
ir
|
||||||
product
|
product
|
||||||
sale
|
sale
|
||||||
|
sale_supply_production
|
||||||
|
production
|
||||||
|
account_invoice
|
||||||
xml:
|
xml:
|
||||||
product.xml
|
product.xml
|
||||||
sale.xml
|
sale.xml
|
||||||
|
|||||||
@@ -7,5 +7,8 @@
|
|||||||
<field name="pizza"/>
|
<field name="pizza"/>
|
||||||
<label name="pizza_topping"/>
|
<label name="pizza_topping"/>
|
||||||
<field name="pizza_topping"/>
|
<field name="pizza_topping"/>
|
||||||
|
<newline/>
|
||||||
|
<label name="boms"/>
|
||||||
|
<field name="boms" xexpand="1"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -3,8 +3,10 @@
|
|||||||
this repository contains the full copyright notices and license terms. -->
|
this repository contains the full copyright notices and license terms. -->
|
||||||
<data>
|
<data>
|
||||||
<xpath expr="//field[@name='reference']" position="after">
|
<xpath expr="//field[@name='reference']" position="after">
|
||||||
|
<newline/>
|
||||||
<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>
|
||||||
|
|||||||
Reference in New Issue
Block a user