5 Commits

Author SHA1 Message Date
24da82aa41 add line of title to the sale 2023-06-28 10:18:35 -05:00
0bfc36b7c2 update production 2023-06-25 01:50:26 -05:00
8049d555f2 add production 2023-06-24 23:02:37 -05:00
e170c152ab delete element expand in label product template 2023-06-25 02:26:56 +00:00
975b64f44f add boms to template product 2023-06-24 10:29:11 -05:00
7 changed files with 90 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
from trytond.pool import Pool
from . import product, sale
from . import product, sale, production
__all__ = ['register']
@@ -9,6 +9,7 @@ def register():
product.Product,
sale.Sale,
sale.Line,
production.Production,
module='sale_fast_food', type_='model')
Pool.register(
module='sale_fast_food', type_='wizard')

View File

@@ -6,6 +6,10 @@ msgctxt "field:product.template,pizza:"
msgid "Pizza"
msgstr "Pizza"
msgctxt "field:product.template,pizza:"
msgctxt "field:product.template,pizza_topping:"
msgid "Topping Pizza"
msgstr "Adiciónes"
msgctxt "field:product.template,boms:"
msgid "Boms"
msgstr "Lista de Materiales"

View File

@@ -1,5 +1,6 @@
from trytond.pool import Pool, PoolMeta
from trytond.model import fields
from trytond.pyson import Eval, Bool
class Product(metaclass=PoolMeta):
@@ -7,4 +8,6 @@ class Product(metaclass=PoolMeta):
__name__ = 'product.template'
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
View 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

12
sale.py
View File

@@ -23,8 +23,13 @@ class Sale(metaclass=PoolMeta):
@classmethod
@ModelView.button
def add_pizza(cls, records):
pool = Pool()
saleLine = pool.get('sale.line')
for record in records:
#raise UserError(str(record.lines))
record.pizza_number +=1
record.lines += (saleLine(type="title",
description="Pizza Combinada"),)
record.save()
@@ -44,3 +49,10 @@ class Line(metaclass=PoolMeta):
super(Line, self).on_change_product()
if self.product.pizza:
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

View File

@@ -4,6 +4,8 @@ depends:
ir
product
sale
sale_supply_production
production
xml:
product.xml
sale.xml

View File

@@ -7,5 +7,8 @@
<field name="pizza"/>
<label name="pizza_topping"/>
<field name="pizza_topping"/>
<newline/>
<label name="boms"/>
<field name="boms" xexpand="1"/>
</xpath>
</data>